Ruby/Array/Range Index

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

set multiple elements at the same time

a[1..3] = ["a", "b", "c"]
puts a.inspect



use ranges as array indices to select multiple elements at the same time:

a = [2, 4, 6, 8, 10, 12]
puts a[1..3].inspect