C# set/get equivalent in squirrel?

Started by EK.IceFlake, Nov 17, 2016, 11:41 AM

Previous topic - Next topic

EK.IceFlake

In C# we can
public string sNub
{
    set
    {
        //...
    }
    get
    {
        //...
        return "nub";
    }
}

so when we
sNub = something
then set will get called and a variable will be created inside it 'value' which will be the something.
in get, whatever we return is the value of that variable

Does squirrel has an equivalent?

Thank you.

KAKAN

Squirrel has _set and _get metamod.
oh no

EK.IceFlake


KAKAN

Quote from: EK.CrystalBlue on Nov 17, 2016, 12:18 PM
Quote from: KAKAN on Nov 17, 2016, 12:16 PMSquirrel has _set and _get metamod.
How to use it?
class test{
function _set(idx, val){ print( "Someone is trying to change the value of '" + idx + "' to '" + val + "'"); }
function _get(idx, val){ print( "Someone is trying to get the value of '" + idx); }
}
More info here:- http://www.squirrel-lang.org/squirreldoc/reference/language/metamethods.html
oh no