Created
January 19, 2014 13:52
-
-
Save takuan-osho/8505273 to your computer and use it in GitHub Desktop.
Go言語でスライスとか文字列関係の勉強をしてみた ref: http://qiita.com/takuan_osho/items/74ef2d970a4888175336
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" | |
"strings" | |
) | |
func main() { | |
s := []string{"ようこそ", "世界"} | |
fmt.Println(strings.Join(s, "")) | |
} |
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" | |
"sort" | |
) | |
func main() { | |
s := []string{"運", "いう", "ウン", "アナタ", "あなた", "うん", "言う", "イウ", "貴方"} | |
sort.Strings(s) | |
fmt.Println(s) | |
} |
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" | |
"sort" | |
) | |
func main() { | |
s := []string{"運", "いう", "ウン", "アナタ", "あなた", "うん", "言う", "イウ", "貴方"} | |
sort.StringSlice(s).Sort() | |
fmt.Println(s) | |
} |
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" | |
"sort" | |
) | |
func main() { | |
s := []string{"運", "いう", "ウン", "アナタ", "あなた", "うん", "言う", "イウ", "貴方"} | |
sort.Sort(sort.Reverse(sort.StringSlice(s))) | |
fmt.Println(s) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment