Lambda vs. Procs : How are values processed?


#1

Test Code

def test
"dog"
end

test #0utput

def test2
puts "dog"
end

test2 #output

"dog"

End Test Code

Please explain the following:

  1. why the first proc did not evaluate "dog" as a string and return the string to output,
    but instead returned "=>dog"? What is the key in this case?

  2. When I ran both methods one after the other the only output I got was "dog".

  3. When I ran both methods and include an arbitrary inline call to a String object instance "dog" the out put was:

"dog
=>dog"


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.