0
votes
2answers
127 views

Ruby and Lambda calculus

I'm trying to understand lambda calculus with procs and ruby. Here is some code: puts -> x { -> y {x.call(y) } } # => #<Proc:0x2a3beb0@C:/first-ruby.rb:1 (lambda)> puts -> x { x + ...
2
votes
2answers
140 views

Can I use a method as a lambda?

I have an interface the defines a group of conditions. it is one of several such interfaces that will live with other models. These conditions will be called by a message queue handler to ...
0
votes
2answers
53 views

What is happening to this lambda ? could someone explain

proc_obj = -> proto { print proto; puts("World")} puts proc_obj["Hi"] puts proc_obj.call("Hello") #Is this is the same as above please refer me to some link to demystify this ...
9
votes
5answers
4k views

Ruby block, procs and instance_eval

I recently tried to do something akin to this: a = "some string" b = Proc.new{ upcase } a.instance_eval b Which gives the error: TypeError: can't convert Proc into String but this works: def ...
11
votes
3answers
2k views

Calling/applying lambda vs. function call - the syntax in Ruby is different. Why?

I am kinda new to Ruby and still trying to understand some of the language design principles. IF I've got it right, the lambda expression call in Ruby must be with square braces, while the "regular" ...
13
votes
2answers
5k views

Ruby: Can lambda function parameters have default values?

I want to do something similar to this: def creator() return lambda { |arg1, arg2 = nil| puts arg1 if(arg2 != nil) puts arg2 ...