Project

General

Profile

Actions

Bug #11005

closed

why block bind can not be in my_method2

Bug #11005: why block bind can not be in my_method2

Added by gagahappy (Happy GaGa) over 10 years ago. Updated over 10 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
2.1.2, 2.2.1
[ruby-core:<unknown>]

Description

class MyClass def my_method1 nice_name = "Lucy" @proc = lambda {|say| "#{say}, #{nice_name}"} nice_name = "Sophy" puts @proc.call 'Hi' # => Hi, Sophy nice_name = "Oleg" puts @proc.call 'Hi' # => Hi, Oleg end def my_method2 nice_name = 'Han' puts @proc.call 'Hey' # => Hey, Oleg **#Expect is "Hey, Han"****  end end obj = MyClass.new obj.my_method1 obj.my_method2 

Updated by matz (Yukihiro Matsumoto) over 10 years ago Actions #1

  • Status changed from Open to Rejected

@proc binds the scope of my_method1, not of my_method2.
We are not going to change that.

Matz.

Updated by nobu (Nobuyoshi Nakada) over 10 years ago Actions #2

  • Description updated (diff)
Actions

Also available in: PDF Atom