Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.ruby Subject: Re: undefined local variable or method `city' for # Date: Fri, 11 Dec 2015 07:09:22 +0100 Lines: 24 Message-ID: References: <9589d281-0b8c-4c61-ba55-6992cc2957c8@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net WYC9qEeNJ7k1aKCR1lVfWwPIbbbHlYBLTX+YnyNqnQeg/HZjU= Cancel-Lock: sha1:yjUP0E+S2bk0W6RyJeko+01eJQs= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 In-Reply-To: <9589d281-0b8c-4c61-ba55-6992cc2957c8@googlegroups.com> Xref: csiph.com comp.lang.ruby:7161 On 11.12.2015 07:00, gengyangcai@gmail.com wrote: > first_name = gets.chomp > last_name = city > > undefined local variable or method `city' for # > > What does "undefined local variable or method `city' for > #" mean? Tried searching in Google, but no results > were returned ... Obviously #city is undefined at the point of execution. You see this effect: $ ruby2.0 -e 'x=city' -e:1:in `
': undefined local variable or method `city' for main:Object (NameError) But we are lacking context - or rather: Context. robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/