Ruby's equivalent to Python's `ary[1:]`
Given an Array foo
, return a sub-array, starting with a given index and going to the end of foo
.
foo = [1, 2, 3, 4]
Python:
foo[1:] # [2, 3, 4]
Ruby:
foo.drop(1) # [2, 3, 4]
Written by Melanie Archer
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#