From: Robert Klemme Date: 2013-03-28T23:56:26+09:00 Subject: Re: undefined local variable or method 'math' On Thu, Mar 28, 2013 at 3:45 PM, Dave Aronson wrote: > On Wed, Mar 27, 2013 at 11:35 PM, Don Pick wrote: > >> math.sqrt(9) >> undefined local variable or method 'math' for main:Object >> >> How do I troubleshoot this? > > To clarify Amalrik's answer: the names of modules and classes and such > are constants. In Ruby this means they start with an uppercase > letter. So, you want "Math", not "math". That is not necessarily true: 1. You can assign a class / module to a local variable or wrap it in a method call. irb(main):001:0> math = Math => Math irb(main):002:0> math.sqrt(9) => 3.0 2. Classes and modules do not even have to have names: irb(main):003:0> cl = Class.new { def foo; 123; end } => # irb(main):004:0> cl.name => nil irb(main):005:0> o = cl.new => #<#:0x80050444> irb(main):006:0> o.foo => 123 Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/