ruby - Ensure all values in user-input array are between 1 and 10 -
i trying define array based on user input , want make sure each value between 1 , 10. how can that?
so using right now.
array = gets.chomp i want user input values ranging 1 10. how do that?
you can use below that:
def verify(input) (1..10).to_a.include?(input) end #input user input if verify(input) #do stuff else #don't stuff end
Comments
Post a Comment