coding for food

[Ruby] arr/string.index(ele) _ arr/string.include?(ele)

silveryen 2022. 7. 26. 11:21
arr = ["NY", "NJ", "FL"]

arr.index("NJ") => 1

# arr/string.index(ele) - evaluates to the index where ele is found

arr.include?("SF") => false # ruby에서  ? 는 Boolean 으로 값을 낸다.

# arr/string.include?(ele) - evaluates to a boolean indicating if ele is found