Back
Close

Introduction to Scala Part3: Option & Pattern Matching

Bubu
230 views

Methods of Option

get

Some(1).get // 1
None.get //java.util.NoSuchElementException: None.get

getOrElse

Some(1).getOrElse(2) // 1
None.getOrElse(2) // 2

Option

Option(1) // Some(1)
Option(null) // None

IsEmpty

Some(1).isEmpty // false
None.isEmpty // true

Map Option

getNameOfPerson
getNameUsingMap
getEmail
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants