GoByte Blog
Engineering lessons and marketing playbooks from the team behind GoByte.
Latest, page 3
RSS-
JavaScript from zero: const does not freeze the fields
const stops a new assignment to the name. It does not freeze the fields. A spread copies the drink. The original stays 450. The tipped copy is 540.
-
JavaScript from zero: a class holds the method
A class puts the fields and the method on one object. new Item makes a latte. label prints latte $4.50.
-
JavaScript from zero: an object has fields
An object groups named fields. A latte has a name and a price in cents. The program prints latte $4.50.
-
JavaScript from zero: a value has a type
typeof reports the type of a value. A latte label uses a number, a string, and a boolean. The program prints latte $4.50 ready, then number string boolean.
-
Java from zero: int division drops the fraction
Dividing two ints drops the fraction. A $5.00 bill split three ways is 166 cents each, not 166.666. The program prints 166. Two cents are left over.
-
Java from zero: null is not an object
A variable can hold null, which means no object. Calling a method on null fails. The program checks first and prints missing.
-
Java from zero: a class holds the data and the method
A class groups fields and a method. Item stores a drink and a price in cents. label prints latte $4.50.
-
Java from zero: a variable has a type
A Java variable has a type. name is a String, cents is an int, and ready is a boolean. The program prints latte $4.50 ready.
-
Go from zero: make the map before you write
A map has to be made before a write. map[string]int{} makes a menu. The program stores 450 under latte and prints 450.
-
Go from zero: zero is a real value
A var with no value is not empty of meaning. A blank order has an empty name and 0 cents. The program prints "" $0.00.
-
Go from zero: a struct is the object
A struct groups named fields, and a method is a function on that struct. Item holds a drink and a price in cents, and Label prints latte $4.50.
-
Go from zero: a name has a type
A Go name has a type. name is a string, cents is an int, and ready is a bool. The program prints latte $4.50 ready.