• We use Go.

    And it needs to be unicode friendly. So you can't rely on ASCII alone, and you need to be fine with unicode runes having a concept of upper and lower.

    http://play.golang.org/p/1qwU7p3urR

    package main
    
    import (
    "fmt"
    	"strings"
    )
    
    func main() {
    	fmt.Println(ShoutToWhisper("Hello, playground"))
    	fmt.Println(ShoutToWhisper("HELLO, PLAYGROUND"))
    }
    
    func ShoutToWhisper(s string) string {
    	if strings.ToUpper(s) == s {
    		s = strings.ToLower(s)
    	}
    
    	return s
    }
    

    By default Go will do sensible things with Unicode strings, but there is also a ToUpperSpecial if the language is known (it's not in our case) as it will disambiguate which runes to consider.

  • It's like C, except you ignore parentheses around conditionals and just forget all that pointer stuff.

    Or it's like JavaScript, except the language has types and forget those parentheses.

    It's lovely.

About