I am new to ruby on rails and started a tutorial and found out the following function
def string_shuffle(s) >> s.split('').?.? >> end => nil >> string_shuffle("foobar")
s.split('').?.? do? I know the split method but i have no idea what the two question marks are for. I saw "? used in boolean methods, but i couldnt understand how this one works. I tried to google it but, I couldnt find it at all.
To quote the tutorial in question:
By replacing the question marks in Listing 4.10 with the appropriate methods, combine split, shuffle, and join to write a function that shuffles the letters in a given string.
Listing 4.10 is an exercise where the two question marks are meant to be replaced with actual method calls.
This code is not valid
You can see split returns an array : http://www.ruby-doc.org/core-1.9.3/String.html#method-i-split
And there is no method called ? in Array : http://www.ruby-doc.org/core-1.9.3/Array.html