Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Return
- class A
- def hello_proc
- a = Proc.new { return 'Hello' }
- a.call
- puts 'PROC'
- end
- def hello_lambda
- a = lambda { return 'Hello' }
- a.call
- puts 'PROC LAMBDA'
- end
- end
- A.new.hello_proc
- A.new.hello_lambda
- # Arguments
- a = Proc.new { |name, first_name, last_name| puts "Hello #{name}" }
- a.call('Dima')
- b = lambda { |name, first_name, last_name| puts "Hello #{name}" }
- b.call('Dima')
- a ||= 2
- puts a.object_id
- a = 2
- puts a.object_id
- a ||= 'Hello'
- puts a.object_id
- a ||= 'Hello'
- puts a.object_id
Add Comment
Please, Sign In to add comment