Skip to content

Instantly share code, notes, and snippets.

@dharnnie
Created December 31, 2020 10:39
Show Gist options
  • Save dharnnie/e7c0bdc22c980e449e7c0a2d857d3051 to your computer and use it in GitHub Desktop.
Save dharnnie/e7c0bdc22c980e449e7c0a2d857d3051 to your computer and use it in GitHub Desktop.
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