ary[1..] # identical to ary[1..-1]
(1..).each {|index| ... } # infinite loop from index 1
ary.zip(1..) {|elem, index| ... } # ary.each.with_index(1) { }
[1, 1, 2, 2, 3, 3, 4, 5 ].difference([1, 2, 4]) #=> [ 3, 3, 5 ]
["a", "b", "c"].union(["c", "d", "a"]) #=> [ "a", "b", "c", "d" ]
["a"].union([["e", "b"], ["a", "c", "b"]]) #=> [ "a", "e", "b", "c" ]
"https://api.github.com/repos/rails/rails"
.yield_self { |url| URI.parse(url) }
.yield_self { |url| Net::HTTP.get(url) }
.yield_self { |response| JSON.parse(response) }
.yield_self { |repo| repo.fetch("stargazers_count") }
.yield_self { |stargazers| "Rails has #{stargazers} stargazers" }
.yield_self { |string| puts string }
Event.upcoming
.then { |events| params[:limit] ? events.limit(params[:limit]) : events }
.then { |events| params[:status] ? events.where(status: status) : events }