Hello
As you all know, I'm a true red ruby coder now, so I decided to set up a thread for us Rubiers. Anyways, I'll start by asking a quick question.
Here is my code showing off my understanding of how lambda functions work, and I was wondering -- at the point of the while loop between the while and the end (of the nested lambda) , would the fixing of the string be returned simply? or would it just keep on looping, or both (set the return item to be the string, but keep going)? Here is the code, which is a Ruby version of a Cemetech-style 'L O L' to '0x5' converter:
Code:
It should work if it doesn't immediately return after the setting on line 4.
EDIT: it even blocks an L then an O and an L together, so that's why there's 5 0x5's there, not because I put them.
As you all know, I'm a true red ruby coder now, so I decided to set up a thread for us Rubiers. Anyways, I'll start by asking a quick question.
Here is my code showing off my understanding of how lambda functions work, and I was wondering -- at the point of the while loop between the while and the end (of the nested lambda) , would the fixing of the string be returned simply? or would it just keep on looping, or both (set the return item to be the string, but keep going)? Here is the code, which is a Ruby version of a Cemetech-style 'L O L' to '0x5' converter:
Code:
StringFunction = lambda {|stringInput, pat, rep| #outwards lambda
replaceAll = lambda {|inputString, pattern, replacement| #nested
while inputString.sub!(pattern, replacement)
inputString = inputString.sub(pattern, replacement)
end
}
replaceAll.call(stringInput, pat, rep)
}
String NonLolzed = StringFunction.call(gets.chomp, " lol ", " 0x5 ")
#finally use all those lambdas :roll:
It should work if it doesn't immediately return after the setting on line 4.
EDIT: it even blocks an L then an O and an L together, so that's why there's 5 0x5's there, not because I put them.