What is Scala?
- Scala fuses OOP and FP
: scala is scalable
- object oriented
- every val is an obj
- every operation is a method call
- scala is functional
- funcs are first-class values
- operations of a program should map input values to output values rather than change data in place
Immutable variables and value types
val
(immutable) :
- double, int, bool, string is the most important
val
(mutable) :
- can be reassigned
- pros and cons
- pros:
- data won't be changed inadvertently
- code is easier to reason about
- have to write fewer tests
- cons
- extra memory required due to dat copying
Scripts, applications and real-world workflows
scala scripts
- a sequence of instructions in a file, executed sequentially
- useful for smaller projects
- at a command prompt, the scala command executes a script by wrapping it in a template and then compiling and executing the resulting program
Interpreted language vs. compiled language
Scala applications
- compiled explicitly then run explicitly
- consist of many source files that can be compiled individually
- useful for longer programs
- no lag time since applications are precompiled
Array
Collections
- mutable
- can be updated/extended in place
- immutable
and Array is mutable.
- Initialize elements of the Array
강사님 ㅋㅋㅋㅋㅋ Bye Alex 무엇 ㅋㅋㅋㅋㅋㅋ
Lists
- Array is mutable and
Lists
is immutable obj
How Lists are useful while immutable
list
has methods, like all of Scala collections
var players = List("A", "B")
players = "C" :: players
<Returns>
palyers: List[String] = List(C, A, B)
Scala's static type system
Scala is Compiled, statically-typed languages.
- Relational and logical operators
who need help improving their coding skills bubble slides, daily game solve cross