Here's a fun thing with ruby arrays - follow along in irb:
using "..." and changing elements at the same time will update the first element specified and insert a new element after that element at the same time.
fun :)
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
irb> a = [1,2,3] | |
=> [1,2,3] | |
irb> a[1..2] | |
=> [2,3] | |
irb> a[1...2] | |
=> [2] | |
irb> a[1...2] = ["two", "three"] | |
=> ['two','three'] | |
irb> a | |
=> [1, "two", "three", 3] |
Comments
Post a Comment