Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala's blend of functional with object-oriented

Tags:

scala

If you were trying to explain someone how nicely Scala blends functional and object-oriented techniques, which example would you use?

like image 298
Nermin Serifovic Avatar asked Nov 16 '10 22:11

Nermin Serifovic


People also ask

Can you mix functional and object-oriented programming?

Rather than going for Functional Programming or Object-Orientated Programming exclusively, you can go for a mixed approach, at in languages that support both such as JavaScript or Python. For example, you can still use classes and then pass a class instance to your function.

What is functional programming and object-oriented programming?

Functional programming is the programming technique that accentuates the functional factors required for creating and implementing the programs. OOP or the Object-Oriented Programs are the conceptual programming techniques that uses objects as the key.


1 Answers

In my canned Seductions of Scala talk, I end with an Actor example that uses functional-style pattern matching for determining the "kind" of message received and object-oriented-style polymorphic dispatch for one of the message "kinds" (a geometric shape to draw). It starts around slide 76.

like image 132
Dean Wampler Avatar answered Sep 19 '22 17:09

Dean Wampler