[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Seemingly inconsistency between function in a local variable and local function
- From: Robert Klemme <shortcutter@...>
- Date: Mon, 2 Apr 2012 16:38:08 +0200
On Mon, Apr 2, 2012 at 2:33 PM, Jerome Vuarand <jerome.vuarand@gmail.com> wrote:
> 2012/4/2 Robert Klemme <shortcutter@googlemail.com>:
>> Why is that? What did I overlook?
>
> Every time you write the keyword "local", you create/declare a new
> local variable, which can shadow another one with the same name.
Ah! I wasn't aware of that. Page http://www.lua.org/pil/4.2.html
does not mention this.
> You can either use
> your syntax, or you can write it like that:
>
> local f2
> local function f1() return f2() end
> function f2() return 123 end -- note the absence of local keyword
Good to know.
Thank you and Steve!
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/