Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 基本形
- arr0 = ["a", "b", "c"]
- # カンマのみならず, 改行でも要素を区切れる
- arr1 = [
- "a", "b", "c"
- "d", "e", "f"
- "g", "h", "i"
- ]
- # カンマ+改行(任意回)でも一つの区切りとして認識
- # 最末尾にカンマを入れてもOK
- # カンマを複数回重ねるとNG
- arr2 = [
- "a", "b", "c",
- "d", "e", "f",
- "g", "h", "i",
- # "j", "k", "l",,, <- NG
- ]
- # 最初の要素は空白を開ける必要あり
- # 2個目以降は空けなくてもOK
- arr3 = [
- "a"
- "b"
- "c"
- ]
- # 1から10までの配列
- arr4 = [1..10] # [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
- # 逆向きも負の数もOK
- arr5 = [10..-1]
- # 小数点もいけるけど1.0ずつ増えていくため末尾の数値が表示されないことがある
- arr6 = [0.1..3.0] # [0.1, 1.1, 2.1]
- # 文字列は無理
- arr7 = ["a".."z"] # [ "a" ]
- # booleanでもいけなくはない
- arr8 = [true..false] # [true, 0]
- arr9 = [false..true] # [false, 1]
- arr10 = [true..3] # [true, 2, 3]
- arr11 = [true..-3] # [true, 0, -1, -2, -3]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement