Created
February 5, 2016 11:00
-
-
Save ha1t/d97f7315ec99a30083ec to your computer and use it in GitHub Desktop.
This file contains hidden or 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 counter int | |
type mystring string | |
func (c *counter) inc() int { *c++; return int(*c) } | |
func (c *counter) dec() int { *c--; return int(*c) } | |
func (s *mystring) first() string { return string(string(*s)[0]) } | |
func main() { | |
var c counter | |
fmt.Println(c.inc()) | |
fmt.Println(c.inc()) | |
var hoge = "hogehoge" | |
fmt.Println(string(hoge[0])) | |
var moge mystring | |
moge = "mogemoge" | |
fmt.Println(moge.first()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment