Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The biggest reason is typo and type checking. Any typo is a compilation error. But the type checking is even more interesting. You basically create a subtype of string which is correspondingly type checked by the compiler. Functions might return a keyword instead of a string.

One funny thing you can do in Go is for example to create a subtype of int and change its String() method to return the hexadecimal representation of that int. Very neat.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: