- Code: Select all
dict = Hashtable()
dict['a'] = 'z'
dict['b'] = 'y'
dict['c'] = 'w'
assert dict['a'] == 'z'
print dict.getType
for de in dict
print de.key, de.value #line 11
gives
hashTbl.cobra(11): error: Cannot find a definition for "key" in "de" whose type is "Object?".
on compilation.
I'm thinking theres a type inference bug here since changing the 'for' stmt to
- Code: Select all
for de as DictionaryEntry in dict
compiles and runs works fine, as does explicit casting in the 'for' body
- Code: Select all
dict = Hashtable()
dict['a'] = 'z'
dict['b'] = 'y'
dict['c'] = 'w'
assert dict['a'] == 'z'
print dict.getType
for de in dict
#print de.key, de.value #line 11
de1 as DictionaryEntry = de to DictionaryEntry
print de1.key, de1.value