- Code: Select all
class Test
var aString as String = 'testing'
pro aString2 from var as String
def init
.aString2 = 'testing2' #or _aString2 = 'testing2'
def printAll
print '[.aString], [.aString2]' #I suppose it could be '[.aString] [_aString2]'
class Program
def main is shared
t = Test()
print t.aString
print t.aString2
t.printAll
t.aString = 'hi'
t.aString2 = 'hi2'
print t.aString
print t.aString2
t.printAll
The only differences seem to be negative on the pro side, in that you can't declare the variable to be something on the same line as the declaration (hence the init...) You could also use _aString2, but it is the same amount of typing as .aString2? Personally I prefer the "." over the _, coming from python