Created
August 20, 2017 21:23
-
-
Save markphelps/b761c99918095b62e9baa6297f4ade50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package optional | |
type String struct { | |
string string | |
present bool | |
} | |
func EmptyString() String { | |
return String{} | |
} | |
func OfString(s string) String { | |
return String{string: s, present: true} | |
} | |
func (o *String) Set(s string) { | |
o.string = s | |
o.present = true | |
} | |
func (o *String) Get() string { | |
return o.string | |
} | |
func (o *String) Present() bool { | |
return o.present | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment