Chapter 3: Typing Variables and Controlling the Flow

Your Turn 1

 1_i8
 16_i16
 132
 164_i64
 264_u64
 p int64 + int32 + uns64 # => 560_i64
 p int8 + int64 # => -91_i8

Your Turn 2

a. splitting.cr

b. utf8.cr: The cat character has unicode codepoint 29483 and takes 3 bytes: 231, 140, and 171.

c. object_id.cr: Strings with the same value have the same object_id for performance. That id, of course, could differ from the value given here.

Integers have no object_id because they are created on the stack.

Your Turn 3

string_symbol.cr: They are not the same.

Your Turn 4

destructuring.cr

Your Turn 5

a. union_types.cr

b. hashes.cr

c. compile_runtime.cr

Your Turn 6

a. var1.cr: The value of var1 is 2; same output for a while instead of if.

b. if_elsif_else.cr: The output is 9 and has one digit.

c. exception_union.cr: The compile-time type of a is (Int32 | Nil); Nil is the type it had when an exception occurred. Use as to ease the compiler.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.120.136