The type of theresultvalue in this example is unspecified so the compiler used type inference to determine the most appropriate type.Either aStringorUnitcould have been returned, so the compiler chose the root classAny.This is the one class common to bothString(which extendsAnyRef) and toUnit(...
As we mentioned above, if the operands have a different type (e.g., the number 1 and the string "1"), JavaScript will attempt to change the type of both operands in order to check if they are equal. This means that expressions will often return equal more easily than if we were ...
5.14Exercises Exercise 1 Fermat’s Last Theorem says that there are no integersa,b, andcsuch that an+bn=cn for any values ofngreater than 2. Write a function namedcheck_fermatthat takes four parameters—a,b,candn—and that checks to see if Fermat’s theorem holds. Ifnis greater than ...