I'm just learning rubies and want to check if there are specific values in the array.
For example, [1,2,3,4,5]
has 3 but not 6.
In other languages, I used to find things like find and index, but I think ruby also has a method that can be used without going around the repetition door.
array ruby
Write include?.
If object
is in self
, return true or false.
myarr = [1,2,3,4,5]
puts myarr.include? 1
puts myarr.include? 10
© 2024 OneMinuteCode. All rights reserved.