Instance variables not accessible from within tha application block

13 views
Skip to first unread message

Aaron Mllr

unread,
Jul 10, 2014, 8:16:32 AM7/10/14
to bluep...@googlegroups.com
The following example returns nil:

-----
class A
  def initialize
    @b = 7
  end

  def run
    Bluepill.application(:testing) do |app|
      puts @b
    end
  end
end

A.new.run
-----

But the following example returned the 7:

-----
class A
  def initialize
    @b = 7
  end

  def run
    c = @b
    Bluepill.application(:testing) do |app|
      puts c
    end
  end
end

A.new.run
-----

Why are instance variables not passed into the application block? Is there some strange context change I can't imagine?

Aaron

Kostya M

unread,
Jul 10, 2014, 9:22:20 AM7/10/14
to bluep...@googlegroups.com
Sure, because Bluepill.application(:testing) is a dsl class itself. so @b related to that dsl class (because it parses with eval). What are you trying to do?


--
You received this message because you are subscribed to the Google Groups "Bluepill" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bluepill-rb...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages