I'm curious to see if anybody knows of any way to produce a non value from a method, function, etc.
I did a fair amount of googling and could not find a good answer to this. Now, of course there are a few ways to express "nothing" in Ruby, including the likes of "nil", "" and "". But these are not truly "nothing".
The reason why I bring this up is because sometimes I have a problem that involves having an array that spits out its selection or collection of indices and one of them happens to be "nil", "", or , when I actually intended that index to not exist at all. While there are ways to use the "break" or "next" commands to skip a loop in the method to perhaps avoid this, I believe I may be doing it wrong. Are there any other ways to accomplish this? Here are some situations that I have been running into problems with:
def ordered_vowel_words(str) # method that presents a string that contains words which have their vowels in alphabetical order words = str.split(" ") ordered =  words.each do |word| ordered << ordered_vowel_word?(word) end ordered = ordered.join(" ") puts ordered return ordered end def ordered_vowel_word?(word) # method that presents the word if its vowels are in alphabetical order vowels =  word.each_char do |char| if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" if (vowels.empty? == false) && (char < vowels.last) word = nil return end vowels << char end end puts word return word end ordered_vowel_words("this is a test of the vowel ordering system") # == this is a test of the vowel "" system # the result should be 'this is a test of the vowel system'