You mix three different concepts. Functional programming, variability, and OOP are three different things.
I was taught that OOP is a change in the state of a given object using publicly available methods.
Yes and no. The important thing in O OP is that you have objects that can transfer data and code (their member methods) at the same time, and that you communicate with objects using their interface so that the object can then
- send a specific implementation of the called method
- provide additional information that is stored in the data that the object carries (access to
thisthe implementation of the method) - execute method implementation code
, , - .
, . , . , , , .
, .
. - , . , : , . - .
, . , . , - . . , , , . , , , . , : , , " ", ,
"", (, ) , ?
, . Scala . , , , . , .
. .
, - . apply(integer i), , , , ,
String.apply(integer i)
/** get value for key `i` */
TreeMap.apply(integer i)
C .
- ?
" ". oop- ( ), . , . , , . , ( : , , , - , ). FP .
. , , ( ), , , ( ).