Created
October 11, 2010 01:54
-
-
Save toby55kij/619851 to your computer and use it in GitHub Desktop.
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
// g100pon #58 StringクラスのGDKメソッド | |
// 1.7.3で追加されたメソッド | |
// capitalize:先頭文字を大文字化 | |
assert 'foo'.capitalize() == 'Foo' | |
// expand:タブを空白に展開 | |
assert '¥tabc'.expand() == ' abc' //引数無しの場合タブは8 | |
assert '¥tdef¥tghi'.expand(4) == ' def ghi' | |
// stripIndent:各行の先頭にある共通な空白を除去 | |
assert ' abc abc¥n def¥n ¥n ghi'.stripIndent() == 'abc abc¥n def¥n¥n ghi' | |
// stripMargin:各行の先頭に当たる文字が現れるまで空白・コントロール文字を除去 | |
assert '''¥t|foo | |
|bar | |
|hoge'''.stripMargin() == 'foo¥nbar¥nhoge' //引数無しの場合先頭文字は| | |
assert '''abc | |
/def'''.stripMargin('/') == 'abc¥ndef' | |
// tr:指定された文字列セットを別の文字列セットに変換 | |
assert 'hello, world.'.tr('a-z', 'A-Z') == 'HELLO, WORLD.' | |
// unexpand:連続した空白をタブに変換 | |
assert ' abc'.unexpand() == '¥tabc' //引数無しの場合空白8つをタブに | |
assert ' def ghi'.unexpand(2) == '¥tdef¥t ghi' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment