On Apr 10, 2:36 pm, westhielke <[email protected]> wrote:
> Hi,
>
> In the week3 lab, the exercise RubyMeta_DefineMethod2 uses
>
>    define_method $my_method.intern do |arg1, arg2| ...........
>
> I looked up the "intern" method and it says that it creates a symbol
> from the string, if it does not already exist. However, I tried
> running this without calling the intern method and I didn't see any
> differences.
If you try with a string containing spaces and do not put it in a
string beforehand, you will see the difference. In this precise case,
where the method name is put in a variable, it does not make any
difference as the name of the string (which is a symbol too) exists
from the point where it is defined. So, when you reach the point where
you define the method name, it takes this symbolic name for the
method.
It is explained in details in one of the resources for the lab:
http://www.codeweblog.com/ruby-symbol/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "ruby-on-rails-programming-with-passion" group.
To unsubscribe from this group, send email to
ruby-on-rails-programming-with-passion-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ruby-on-rails-programming-with-passion?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to