Ruby Array Exercises: Check whether a value exists in an array
Ruby Array: Exercise-1 with Solution
Write a Ruby program to check whether a value exists in an array.
color = ["Red", "Green", "Blue", "White"] print "Original array:\n" print color print "\nCheck if 'Green' in color array!\n" print color.include? 'Green' print "\nCheck if 'Pink' in color array!\n" print color.include? 'Pink'
Original array: ["Red", "Green", "Blue", "White"] Check if 'Green' in color array! true Check if 'Pink' in color array! false
Ruby Code Editor:
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework