Created
December 31, 2020 10:39
-
-
Save dharnnie/e7c0bdc22c980e449e7c0a2d857d3051 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 main | |
import "fmt" | |
type Perishable string | |
func main(){ | |
tomatoes := newPerishable("Tomatoes") | |
fmt.Println("Before freezing: ",tomatoes) | |
frozen := tomatoes.freeze() | |
fmt.Println("After freezing: ",frozen) | |
} | |
func newPerishable(name string)Perishable{ | |
return Perishable(name) | |
} | |
func (p Perishable) freeze()Perishable{ | |
return "Frozen "+ p | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment