ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Introducing Lua
Subject:   Is this a Typo?
Date:   2008-02-26 14:49:35
From:   MrSheen

On the "Introducing Lua" page you have this code:


t = {}
t.Name = Fred


function t:sayhello()
print (Hello..self.Name)
end


t:sayhello()
-- Or, other expressions that mean the same thing:
t.sayhello(t)
t['sayhello'](t)


Shouldn't the first part of this code read as follows:


t = {}
t.Name = "Fred"


function t:sayhello()
print ("Hello"..self.Name)
end


Without these two change I get runtime errors with Hello and Fred reported as unknown globals. Or am I missing something here?




PS: Some sort of message post preview button would be nice ;)




Jussi Jumppanen


Author: Zeus for Windows IDE


http://www.zeusedit.com