I want to use the alphabetize method on numbers array with dot syntax/notation (I’m not sure what exactly its called)
I know I can use it as:
but I want to be able use it as this as well:
I know this is possible for strings. I tried using it on the capitalizing exercise.
When I try the latter, the output is :
undefined method `alphabetize’ for [0, 1, 1, 2, 3, 3, 4, 5, 6, 6, 7, 7, 9, 32]:Array
I searched the web and it seems I can use arrays as any parameter for methods.
def alphabetize (array, rev = false) array.sort! if rev != true return array else array.reverse! end end numbers = [1,2,4,5,1,6,7,3,32,6,7,3,0,9] puts numbers.alphabetize
This code returns the error message above.
What am I missing here?
Any help would be very much appreciated as I can’t really find on the web an enough-technical answer to my question which matches my skill level.