complex128.go 558 B

123456789101112131415161718192021222324252627282930313233343536
  1. package optional
  2. type Complex128 struct {
  3. isSet bool
  4. value complex128
  5. }
  6. func NewComplex128(value complex128) Complex128 {
  7. return Complex128{
  8. true,
  9. value,
  10. }
  11. }
  12. // EmptyComplex128 returns a new Complex128 that does not have a value set.
  13. func EmptyComplex128() Complex128 {
  14. return Complex128{
  15. false,
  16. 0,
  17. }
  18. }
  19. func (i Complex128) IsSet() bool {
  20. return i.isSet
  21. }
  22. func (i Complex128) Value() complex128 {
  23. return i.value
  24. }
  25. func (i Complex128) Default(defaultValue complex128) complex128 {
  26. if i.isSet {
  27. return i.value
  28. }
  29. return defaultValue
  30. }