pro vs var
Posted: Wed Nov 12, 2008 12:53 pm
with the new pro name from var as type construct, I am wondering why not simply to use var name as type...? Is there any functional difference (implementation is different, sure):
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
- 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