Skip to content

Instantly share code, notes, and snippets.

@osdrv
Created March 15, 2012 06:23
Show Gist options
  • Save osdrv/2042453 to your computer and use it in GitHub Desktop.
Save osdrv/2042453 to your computer and use it in GitHub Desktop.
different types compatibility
print( null + 1 ); // raises NullPointerException
print( "asdasd" + 123 ); // => asdasd123
print( "asdasd" - 123 ); // raises NoSuchMethodException "-"
print( 0 / 0 ); // => NaN
print( "asd" * 3 ); // raises NoSuchMethodException "*"
print( "asd" / 3 ); // same
print( 3 * "asd" ); // raises NoSuchMethodException: method not found: 'mulFromInteger'
Static a () => 1;
print( a ); // => Closure
print( [ 123, 456 ] + [ 1 ] ); // raises NoSuchMethodException
print( { "q": "asd" } + { "r": "zxc" } ); // raises NoSuchMethodException
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment