\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{lis186} \pdfinfo{ /Title (pkl-cheat-sheet.pdf) /Creator (Cheatography) /Author (lis186) /Subject (Pkl Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{3C572D} \definecolor{LightBackground}{HTML}{F8F9F8} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Pkl Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{lis186} via \textcolor{DarkBackground}{\uline{cheatography.com/200657/cs/42381/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}lis186 \\ \uline{cheatography.com/lis186} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 13th February, 2024.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{x{2 cm} x{6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Comments}} \tn % Row 0 \SetRowColor{LightBackground} Line comment & // Single-line comment \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Block comment & /* First line \{\{nl\}\} Second line */ \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Doc comment & /// A {\emph{bird}} superstar. \{\{nl\}\}/// Unfortunately, extinct.\{\{nl\}\}dodo: Bird \tn % Row Count 7 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.192 cm} x{3.42 cm} x{0.988 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Integers}} \tn % Row 0 \SetRowColor{LightBackground} decimal & 123 & 123 \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} hexadecimal & 0x012AFF & 76543 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} binary & 0b00010111 & 23 \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} octal & 0o755 & 493 \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} decimal with underscore & 1\_000\_000 & \seqsplit{1000000} \tn % Row Count 6 (+ 2) % Row 5 \SetRowColor{white} hexadecimal with underscore & 0x0134\_64DE & \seqsplit{0x013464DE} \tn % Row Count 8 (+ 2) % Row 6 \SetRowColor{LightBackground} binary with underscore & 0b0001\_0111 & \seqsplit{0b00010111} \tn % Row Count 10 (+ 2) % Row 7 \SetRowColor{white} octal with underscore & 0o0134\_6475 & \seqsplit{0o01346475} \tn % Row Count 12 (+ 2) % Row 8 \SetRowColor{LightBackground} To restrict an integer's range & clientPort: UInt16 & \tn % Row Count 14 (+ 2) % Row 9 \SetRowColor{white} To restrict an integer's range & serverPort: Int(isBetween(0, 1023)) & \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{4.4 cm} p{3.6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Comparison operators for integers}} \tn % Row 0 \SetRowColor{LightBackground} 5 == 2 & false \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 5 \textless{} 2 & false \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 5 \textgreater{} 2 & true \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} 5 \textless{}= 2 & false \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} 5 \textgreater{}= 2 & true \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{2.204 cm} p{1.064 cm} x{4.332 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Arithmetic operators for integers}} \tn % Row 0 \SetRowColor{LightBackground} 5 + 2 & 7 & \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 5 - 2 & 3 & \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 5 * 2 & 10 & \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} 5 / 2 & 2.5 & always Float \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} 5 \textasciitilde{}/ 2 & 2 & always Int \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} 5 \% 2 & 1 & always Int \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} 5 ** 2 & 25 & \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.56 cm} x{3.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Floats}} \tn % Row 0 \SetRowColor{LightBackground} .23 & 0.23 \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 1.23 & 1.23 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 1.23e2 & 123 \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} 1.23e-2 & 0.0123 \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} NaN & not a number \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} Infinity & positive infinity \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} -Infinity & negative infinity \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} To Restrict a float to a finite value & x: Float(isFinite) \tn % Row Count 9 (+ 2) % Row 8 \SetRowColor{LightBackground} To restrict a float's range & y: \seqsplit{Float(isBetween(0}, 10e6)) \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.8 cm} x{5.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Booleans}} \tn % Row 0 \SetRowColor{LightBackground} Boolean & true or false \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.572 cm} x{3.192 cm} p{0.836 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Logical operators for Booleans}} \tn % Row 0 \SetRowColor{LightBackground} logical conjunction & true \&\& false & false \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} logical disjunction & true || false & true \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} logical negation & !false & true \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} exclusive disjunction & true.xor(false) & true \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} logical implication & \seqsplit{true.implies(false)} & false \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.04 cm} x{4.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Strings}} \tn % Row 0 \SetRowColor{LightBackground} String & "Hello, World!" \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Multiline string & """ Although the Dodo is extinct, \{\{nl\}\}the species will be remembered. """ \tn % Row Count 5 (+ 4) % Row 2 \SetRowColor{LightBackground} Unicode & "\textbackslash{}u\{26\} \textbackslash{}u\{E9\} \textbackslash{}u\{1F600\}" \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} To concatenate strings & "abc" + "def" + "ghi" \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} String Interpolation & name = "Dodo"\{\{nl\}\}greeting = "Hi, \textbackslash{}(name)!" \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} Custom String Delimiters & \#" \textbackslash{}\textbackslash{}\textbackslash{}\textbackslash{}\textbackslash{} """"" "\# \tn % Row Count 13 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Inside a string literal, the following character escape sequences have special meaning: \newline \newline \textbackslash{}t - tab \newline \textbackslash{}n - line feed \newline \textbackslash{}r - carriage return \newline \textbackslash{}" - verbatim quote \newline \textbackslash{}\textbackslash{} - verbatim backslash} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{6.4 cm} p{1.6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{String API}} \tn % Row 0 \SetRowColor{LightBackground} "dodo".length & 4 \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} "dodo".reverse() & "odod" \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} "dodo".contains("alive") & false \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} " dodo ".trim() & "dodo" \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.08 cm} x{5.92 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Dynamic objects vs.Typed Objects}} \tn % Row 0 \SetRowColor{LightBackground} Dynamic object & Schema-less data models that are not validated \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Typed object & Schema-backed data models that are validated \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.8 cm} x{5.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Objects}} \tn % Row 0 \SetRowColor{LightBackground} Object with properties & `dodo \{\{\{nl\}\} name = "Dodo"\{\{nl\}\} extinct = true\{\{nl\}\} \}` \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Nested object & `dodo \{\{\{nl\}\} name = "Dodo"\{\{nl\}\} taxonomy \{\{\{nl\}\} \textbackslash{}`class\textbackslash{}` = "Aves"\{\{nl\}\} \}\{\{nl\}\} \}` \tn % Row Count 7 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{An object is an ordered collection of values indexed by name. \newline An object's key–value pairs are called its properties. \newline Property values are lazily evaluated on the first read.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Typed Objects}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{class Bird \{ \newline name: String \newline lifespan: Int \newline migratory: Boolean \newline \} \newline \newline pigeon = new Bird \{ \newline name = "Pigeon" \newline lifespan = 8 \newline migratory = false \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Amending Objects}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{pigeon \{ \newline name = "Turtle dove" \newline extinct = false \newline \} \newline \newline parrot = (pigeon) \{ \newline name = "Parrot" \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Transforming Objects}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{dodo \{ \newline name = "Dodo" \newline extinct = true \newline \} \newline \newline dodo \newline .toMap() \newline .remove("name") \newline .toDynamic()} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Converting untyped objects to typed objects}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{class Bird \{ \newline name: String \newline lifespan: Int \newline \} \newline \newline pigeon = new Dynamic \{ \newline name = "Pigeon" \newline lifespan = 8 \newline \}.toTyped(Bird)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Late Binding}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{penguin \{ \newline eggIncubation = 40.d \newline adultWeightInGrams = eggIncubation.value * 100 \newline \} \newline adultWeightInGrams = \seqsplit{penguin.adultWeightInGrams} \newline \newline madeUpBird = (penguin) \{ \newline eggIncubation = 11.d \newline \} \newline adultWeightInGrams = \seqsplit{madeUpBird.adultWeightInGrams}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Hidden Properties}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{class Bird \{ \newline name: String \newline lifespan: Int \newline hidden nameAndLifespanInIndex = "\textbackslash{}(name), \textbackslash{}(lifespan)" \newline nameSignWidth: UInt = \seqsplit{nameAndLifespanInIndex.length} \newline \} \newline \newline /{\emph{ \newline pigeon \{ \newline name = "Pigeon" \newline lifespan = 8 \newline nameSignWidth = 9 \newline \} \newline }}/ \newline \newline pigeon = new Bird \{ \newline name = "Pigeon" \newline lifespan = 8 \newline \} \newline \newline pigeonInIndex = \seqsplit{pigeon.nameAndLifespanInIndex} \newline // pigeonInIndex = "Pigeon, 8" \newline \newline pigeonDynamic = pigeon.toDynamic() \newline /{\emph{ \newline pigeonDynamic \{ \newline name = "Pigeon" \newline lifespan = 8 \newline nameSignWidth = 9 \newline \} \newline }}/} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Local properties}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{class Bird \{ \newline name: String \newline lifespan: Int \newline local separator = "," \newline hidden nameAndLifespanInIndex = "\textbackslash{}(name)\textbackslash{}(separator) \textbackslash{}(lifespan)" \newline \} \newline \newline pigeon = new Bird \{ \newline name = "Pigeon" \newline lifespan = 8 \newline \} \newline \newline pigeonInIndex = \seqsplit{pigeon.nameAndLifespanInIndex} \newline pigeonSeparator = pigeon.separator // Error} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Fixed properties}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{class Bird \{ \newline wingspan: Int \newline weight: Int \newline fixed wingspanWeightRatio: Float = wingspan / weight \newline \} \newline \newline bird = (Bird) \{ \newline wingspan = 10 \newline weight = 8 \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{A property with the fixed modifier cannot be assigned to or amended when defining an object of its class.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Extending a class with fixed properties}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{abstract class Bird \{ \newline fixed canFly: Boolean \newline name: String \newline \} \newline \newline class Penguin extends Bird \{ \newline canFly = false // Error: missing modifier fixed. \newline fixed name = "Penguin" // Error: modifier fixed cannot be applied to property name. \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Const properties}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{const laysEggs: Boolean = true \newline \newline const examples: Listing\textless{}String\textgreater{} = new \{ \newline "Pigeon" \newline "Hawk" \newline "Penguin" \newline \} \newline \newline pigeonName: String = "Pigeon" \newline \newline const function birdLifespan(i: Int): Int = (i / 4).toInt() \newline \newline class Bird \{ \newline name: String \newline lifespan: Int \newline \} \newline \newline const bird: Bird = new \{ \newline name = pigeonName // Error: cannot reference non-const property pigeonName from a const property. \newline lifespan = birdLifespan(24) // Allowed: birdLifespan is const. \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Because const members can only reference its own values, or other const members, they are not late bound.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{6.48 cm} x{1.52 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Durations}} \tn % Row 0 \SetRowColor{LightBackground} nanoseconds (smallest unit) & 5.ns \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} microseconds & 5.us \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} milliseconds & 5.ms \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} seconds & 5.s \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} minutes & 5.min \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} hours & 5.h \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} days (largest unit) & 3.d \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} negative duration & -5.min \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} duration with floating point value & \seqsplit{5.13.min} \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{5.68 cm} p{2.32 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Comparison operators for durations}} \tn % Row 0 \SetRowColor{LightBackground} 5.min == 3.s & false \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 5.min \textless{} 3.s & false \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 5.min \textgreater{} 3.s & true \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} 5.min \textless{}= 3.s & false \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} 5.min \textgreater{}= 3.s & true \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.12 cm} x{4.88 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Arithmetic operators for durations}} \tn % Row 0 \SetRowColor{LightBackground} 5.min + 3.s & 5.05.min \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 5.min - 3.s & 4.95.min \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 5.min * 3 & 15.min \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} 5.min / 3 & 1.6666666666666667.min \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} 5.min / 3.min & 1.6666666666666667 \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} 5.min \textasciitilde{}/ 3 & 1.min \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} 5.min \textasciitilde{}/ 3.min & 1 \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} 5.min \% 3 & 2.min \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} 5.min ** 3 & 125.min \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{The value component can be an expression: \newline x = 5 \newline xMinutes = x.min \newline y = 3 \newline xySeconds = (x + y).s} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{6.88 cm} p{1.12 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Data sizes with decimal unit (factor 1000)}} \tn % Row 0 \SetRowColor{LightBackground} bytes (smallest unit) & 5.b \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} kilobytes & 5.kb \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} megabytes & 5.mb \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} gigabytes & 5.gb \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} terabytes & 5.tb \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} petabytes (largest unit) & 5.pb \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{6.88 cm} p{1.12 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Data sizes with binary unit (factor 1024)}} \tn % Row 0 \SetRowColor{LightBackground} bytes (smallest unit) & 5.b \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} kilobytes & 5.kb \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} megabytes & 5.mb \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} gigabytes & 5.gb \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} terabytes & 5.tb \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} petabytes (largest unit) & 5.pb \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.88 cm} x{5.12 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Arithmetic operators for data sizes}} \tn % Row 0 \SetRowColor{LightBackground} 5.mb + 3.kib & 5.003072.mb \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 5.mb - 3.kib & 4.996928.mb \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 5.mb * 3 & 15.mb \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} 5.mb / 3 & 1.6666666666666667.mb \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} 5.mb / 3.mb & 1.6666666666666667 \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} 5.mb \textasciitilde{}/ 3 & 1.mb \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} 5.mb \textasciitilde{}/ 3.mb & 1 \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} 5.mb \% 3 & 2.mb \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} 5.mb ** 3 & 125.mb \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{The value component can be an expression: \newline x = 5 \newline xMegabytes = x.mb \newline y = 3 \newline xyKibibytes = (x + y).kib} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{5.76 cm} p{2.24 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Comparison operators for data sizes}} \tn % Row 0 \SetRowColor{LightBackground} 5.mb == 3.kib & false \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 5.mb \textless{} 3.kib & false \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 5.mb \textgreater{} 3.kib & true \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} 5.mb \textless{}= 3.kib & false \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} 5.mb \textgreater{}= 3.kib & true \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}