In the following code:
main() {
print('Starting....');
int x = 10;
int y = x > 3 ? 'aaa' : 7;
print(y);
}
This is the output:
Starting....
Unhandled exception:
type 'String' is not a subtype of type 'int'
#0 main (file:///tmp/main.dart:4:12)
#1 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
#2 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
why isn't there a compile time error on the assignment to y? Why only runtime error?
version: Dart VM version: 2.8.4 (stable) (Unknown timestamp) on "linux_x64"
Thanks!