You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think we should not use Option.get in our code. When the object in question is None, the error message is a cryptic NoSuchElementException: None.get. Instead, we should use Option.getOrElse(throw new Exception(exceptionMsg)) so that it is easier to discover where and why the object was None in the first place.
The text was updated successfully, but these errors were encountered:
I tend to agree - the only exception might be when the scope is super local and known for sure there is an element (e.g. with an if check beforehand on option.isDefined)
Yeah, that makes sense. At least it reduces a level of nesting. Also if the variable is volatile you might run into race conditions between the check and the dereference.
I think we should not use
Option.get
in our code. When the object in question isNone
, the error message is a crypticNoSuchElementException: None.get
. Instead, we should useOption.getOrElse(throw new Exception(exceptionMsg))
so that it is easier to discover where and why the object wasNone
in the first place.The text was updated successfully, but these errors were encountered: