Here is my sample code: class Foo Bar = 10 end Foo::Bar # => 10 Foo::Bar.class # => Fixnum 10.class # => Fixnum Float::NAN # => NaN Float::NAN.class # => Float NaN.class # uninitialized constant NaN (NameError) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/de3cdc9a4194cb3810d5585cb6336f70%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
class Foo Bar = 10 end # => 10 Foo::Bar # => 10 Foo::Bar.class #=> Fixnum Bar.class NameError: uninitialized constant Object::Bar from (irb):6 from /usr/local/ruby-1.9.2/bin/irb:12:in `<main>'' On Tuesday, August 27, 2013 6:20:07 AM UTC-4, Ruby-Forum.com User wrote:> > Here is my sample code: > > > class Foo > Bar = 10 > end > > Foo::Bar # => 10 > Foo::Bar.class # => Fixnum > 10.class # => Fixnum > > Float::NAN # => NaN > Float::NAN.class # => Float > NaN.class > # uninitialized constant NaN (NameError) > > -- > Posted via http://www.ruby-forum.com/. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/32254486-51ae-438a-9258-d915ea135986%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
NAN is namespaced under Float. So you can only access it through Float::NAN. -- Dheeraj Kumar On Tuesday 27 August 2013 at 6:08 PM, jsnark wrote:> class Foo > Bar = 10 > end # => 10 > Foo::Bar # => 10 > Foo::Bar.class #=> Fixnum > Bar.class > NameError: uninitialized constant Object::Bar > from (irb):6 > from /usr/local/ruby-1.9.2/bin/irb:12:in `<main>'' > > On Tuesday, August 27, 2013 6:20:07 AM UTC-4, Ruby-Forum.com (http://Ruby-Forum.com) User wrote: > > Here is my sample code: > > > > > > class Foo > > Bar = 10 > > end > > > > Foo::Bar # => 10 > > Foo::Bar.class # => Fixnum > > 10.class # => Fixnum > > > > Float::NAN # => NaN > > Float::NAN.class # => Float > > NaN.class > > # uninitialized constant NaN (NameError) > > > > -- > > Posted via http://www.ruby-forum.com/. > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/32254486-51ae-438a-9258-d915ea135986%40googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/AB56DB7A5D974897A92DE95577D9F274%40gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Dheeraj Kumar wrote in post #1119707:> NAN is namespaced under Float. So you can only access it through > Float::NAN. > > -- > Dheeraj KumarFloat::NAN # => NaN . Does it mean constant `NaN` holds the value also `NaN` ? As `Float::NAN.class` gives us the class name back `Float`.. I am confused in this point.. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7ce468cd9af16150b3506a9579302f10%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
Float::NAN is a constant which holds a special float value `NaN` -- Dheeraj Kumar On Tuesday 27 August 2013 at 8:04 PM, Love U Ruby wrote:> Dheeraj Kumar wrote in post #1119707: > > NAN is namespaced under Float. So you can only access it through > > Float::NAN. > > > > -- > > Dheeraj Kumar > > > > > > Float::NAN # => NaN . > > Does it mean constant `NaN` holds the value also `NaN` ? As > `Float::NAN.class` gives us the class name back `Float`.. I am confused > in this point.. > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7ce468cd9af16150b3506a9579302f10%40ruby-forum.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/BAA15FEFC2154EAE882C09A3079F7D18%40gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Dheeraj Kumar wrote in post #1119714:> Float::NAN is a constant which holds a special float value `NaN`@Dheeraj You are right..But my confusion is why then `instance_of?` and `#class` are going against of each other? :) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c71ccee8312d6c0ab755c7e3f46c9a37%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
Can you post the code you''re confused with? -- Dheeraj Kumar On Tuesday 27 August 2013 at 8:45 PM, Love U Ruby wrote:> Dheeraj Kumar wrote in post #1119714: > > Float::NAN is a constant which holds a special float value `NaN` > > > @Dheeraj You are right..But my confusion is why then `instance_of?` and > `#class` are going against of each other? :) > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c71ccee8312d6c0ab755c7e3f46c9a37%40ruby-forum.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/24B4BD9EA6FD4C7FB5622C5DAE720379%40gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Dheeraj Kumar wrote in post #1119723:> Can you post the code you''re confused with?See here :- C:\>irb --simple-prompt>> Float::NAN=> NaN>> Float::NAN.class=> Float>> Float::NAN.instace_of?(Float)NoMethodError: undefined method `instace_of?'' for NaN:Float from (irb):3 from C:/Ruby193/bin/irb:12:in `<main>''>>-- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/03a466da016a265fe4ed8b12c6c13f3b%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
You spelt it wrong. instance_of?, not instace_of? -- Dheeraj Kumar On Tuesday 27 August 2013 at 9:06 PM, Love U Ruby wrote:> Dheeraj Kumar wrote in post #1119723: > > Can you post the code you''re confused with? > > > See here :- > > > C:\>irb --simple-prompt > > > Float::NAN > > > > => NaN > > > Float::NAN.class > > > > => Float > > > Float::NAN.instace_of?(Float) > > > > NoMethodError: undefined method `instace_of?'' for NaN:Float > from (irb):3 > from C:/Ruby193/bin/irb:12:in `<main>'' > > > > > > > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/03a466da016a265fe4ed8b12c6c13f3b%40ruby-forum.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/608AAB3CAEEA412BBC4F9CF7BA5C26C9%40gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
On 27 August 2013 15:34, Love U Ruby <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Dheeraj Kumar wrote in post #1119707: >> NAN is namespaced under Float. So you can only access it through >> Float::NAN. >> >> -- >> Dheeraj Kumar > > > Float::NAN # => NaN . > > Does it mean constant `NaN` holds the value also `NaN` ? As > `Float::NAN.class` gives us the class name back `Float`.. I am confused > in this point..I /think/ that what is happening there is that the displayed text => NaN is the result of ruby attempting to print the value of Float::NAN. There is no constant NaN, it is just text displayed when it tries to print the value of the Float constant Float::NAN. In other words Float::NAN is a constant which is not actually any number at all and when printed displays as NaN to show that it is not a number. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLshZ_L8DTy3vJgzLMYyyNwVOg-c%3DJPMtSmtC07c_sG%2B1g%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Dheeraj Kumar wrote in post #1119727:> You spelt it wrong. > > instance_of?, not instace_of?OMG!! Thanks for the pointer. What value `Float::NAN` contains ? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1b6a77abc3ff72d34edb23055d106d73%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
Dheeraj Kumar
2013-Aug-27 16:17 UTC
Re: Re: Re: Re: Re: Re: Why NaN.class throws NameError ?
Float::NAN contains a special float value NaN. -- Dheeraj Kumar On Tuesday 27 August 2013 at 9:44 PM, Love U Ruby wrote:> Dheeraj Kumar wrote in post #1119727: > > You spelt it wrong. > > > > instance_of?, not instace_of? > > > OMG!! Thanks for the pointer. > > What value `Float::NAN` contains ? > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1b6a77abc3ff72d34edb23055d106d73%40ruby-forum.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/E291396C6A4B4BA4A52F01954985016B%40gmail.com. For more options, visit https://groups.google.com/groups/opt_out.