complex64.go 541 B

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