Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Array
a = [1, 3, 5]
b = [
1
3
5
]
# a bの中身は同じ値。ただしbの場合、インデントは必須
# ..
# 0~5
m = [0..5]
# 0~4
n = [0...5]
console.log m[1..3] # 1, 2, 3
console.log m[..3] # 0, 1, 2, 3
console.log m[1..] # 1, 2, 3, 4, 5
console.log m[..] # 0, 1, 2, 3, 4, 5
console.log m[1..-2] # 1, 2, 3, 4
m[0..1] = ['a', 'b', 'c'] # a, b, c, 2, 3, 4, 5
console.log m
console.log 'world'[1..3] # orl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment