Hi all,
I'm a newbie of using squirrel script. It's a powerful script lang. I like it very much. But I have a problem about delegation introduced in the document.
// original code snippet in the doc
Entity <- {}
function Entity::DoStuff()
{
::print(_name);
}
local newentity = {
_name="I’m the new entity"
}
newentity.setdelegate(Entity)
newentity.DoStuff();
It will print “I’m the new entity”, but when I assign a new variable also named "_name", it just does not work as expected.
local _name = "outside scope"
Entity <- {}
function Entity::DoStuff()
{
::print(_name);
}
local newentity = {
_name="I’m the new entity"
}
newentity.setdelegate(Entity)
newentity.DoStuff();
is there anything wrong about it? or I just misunderstand about "Delegation" in squirrel? any suggestions about how to write it correctly in this situation?
Thanks