Given this code I would never expect to print “Letter”:
class Letter {
function PrintLetter() {
Debug.Log( "Letter");
}
}
class LetterA extends Letter {
function PrintLetter() {
Debug.Log( "LetterA");
}
}
class LetterB extends Letter {
function PrintLetter() {
Debug.Log( "LetterB");
}
}
private var letterA : Letter = LetterA();
private var letterB : Letter = LetterB();
private var anyLetter : Letter;
private var anyObject;
function Start () {
anyLetter = letterA;
anyObject = letterA;
letterA.PrintLetter();
letterB.PrintLetter();
anyLetter.PrintLetter();
anyObject.PrintLetter();
}
The output is:
- Letter
- Letter
- Letter
- LetterA
The only correct answer is the last once which doesn’t work with #pragma strict, thus not working on the iPhone.
Am I missing something ?