Skip to content

Instantly share code, notes, and snippets.

@morishin
Created July 20, 2020 10:46
Show Gist options
  • Save morishin/7ffa321f318206bb15ded131106aaba1 to your computer and use it in GitHub Desktop.
Save morishin/7ffa321f318206bb15ded131106aaba1 to your computer and use it in GitHub Desktop.

listmonster

head

irb(main):005:0> a = [1, 2, 3]
=> [1, 2, 3]
irb(main):007:0> a.first
=> 1
irb(main):008:0> a
=> [1, 2, 3]

tail

irb(main):005:0> a = [1, 2, 3]
=> [1, 2, 3]
irb(main):009:0> a.drop(1)
=> [2, 3]
irb(main):010:0> a
=> [1, 2, 3]

init

irb(main):010:0> a
=> [1, 2, 3]
irb(main):011:0> a[0...-1]
=> [1, 2]
irb(main):012:0> a
=> [1, 2, 3]

last

irb(main):013:0> a
=> [1, 2, 3]
irb(main):014:0> a.last
=> 3
irb(main):015:0> a
=> [1, 2, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment