Skip to content

Commit

Permalink
Add String Template slides
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstaeding committed Oct 3, 2023
1 parent ea002f3 commit a8dc650
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
30 changes: 29 additions & 1 deletion lecture/03_Variablen/03_Variablen.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% !TeX document-id = {dc20ae76-71b7-4d65-b662-f71c46d32e15}
\usepackage{blkarray}% !TeX document-id = {dc20ae76-71b7-4d65-b662-f71c46d32e15}
% !TeX TXS-program:compile = txs:///pdflatex/[--shell-escape]
\input{../global.tex}

Expand Down Expand Up @@ -97,6 +97,34 @@ \subsection{Zuweisung}
% \maketitle
%\subtitle{Konsoleneingabe}


\section{Exkurs: String Templates}
\begin{frame}
\slidehead

\begin{itemize}[<+->]
\item \textbf{Ziel}: Ausdrücke in einem \inlinekotlin{String} einfügen
\item Kann man so machen
\kotlinfile{listings/string_no_template.kts}
\item Aber so ist besser
\kotlinfile{listings/string_template.kts}
\end{itemize}
\end{frame}

\begin{frame}
\slidehead

\begin{itemize}[<+->]
\item \textbf{Problem}: Komplexere Ausdrücke gehen nicht
\kotlinfile{listings/string_template_complex_mistake.kts}
\item \textbf{Lösung}: Geschweifte klammern \inlinekotlin{\$\{ ... \}}
\kotlinfile{listings/string_template_complex.kts}
\end{itemize}
\begin{block}{Hinweis}
Ausdrücke mit \inlinekotlin{.} brauchen die Klammern
\end{block}\
\end{frame}

\section{Exkurs: Konsoleneingabe}
\begin{frame}
\slidehead
Expand Down
2 changes: 2 additions & 0 deletions lecture/03_Variablen/listings/string_no_template.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
val x = 5
val result = "The result is " + x + " euros"
2 changes: 2 additions & 0 deletions lecture/03_Variablen/listings/string_template.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
val x = 5
val result = "The result is $x euros"
2 changes: 2 additions & 0 deletions lecture/03_Variablen/listings/string_template_complex.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
val y = "Fritz"
val result = "Your name has ${y.length} letters"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
val y = "Fritz"
val result = "Your name has $y.length letters"

0 comments on commit a8dc650

Please sign in to comment.