Created
November 14, 2012 16:42
-
-
Save aeg/4073212 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
// Case #1 | |
// リストを任意の値で埋める | |
def list = [255] * 5 | |
assert list == [255, 255, 255, 255, 255 ] | |
// Case #2 | |
// リストをリストの繰り返しで設定する | |
def list2 = [1, 2, 3] * 3 | |
assert list2 == [1, 2, 3, 1, 2, 3, 1, 2, 3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment