a = [1,2,3,4,5]
a.include?(3) # => true
a.include?(9) # => false
You can find more info regarding rails array here.To add hashes into an array and sort it:
array = Array.new
array << {a: "zach", b: "z"}
array << {a: "john", b: "j"}
array << {a: "peter", b: "pet"}
array.sort_by{ |hash| hash[:a] }
No comments:
Post a Comment