January 2020
Intermediate to advanced
532 pages
13h 31m
English
We can always add new constructor functions to make it easier for creating objects. Using keyword arguments solves the following two problems:
Let's go ahead and define a new constructor as follows:
function TextStyle(; font_family, font_size, font_weight = "Normal", foreground_color = "black", background_color = "white", alignment = "left", rotation = 0) return TextStyle( font_family, font_size, font_weight, foreground_color, background_color, alignment, rotation)end
Here, we have elected to provide default values for most of the fields except font_family and font_size. It is simply defined as a function that provides keyword arguments for all fields ...
Read now
Unlock full access