scala - Why is there an Option.get method -


why method get defined in option , not in some?

one apply pattern matching or use foreach, map, flatmap, getorelse preferred anyway without danger of runtime exceptions if none.get called.

are there cases get method convinent justifies this? using get method reminds me java "i don't have check null because know var set" , see nullpointerexception.

option.get useful when know, reasoning isn't captured type system, value have not none. however, should reach when you've tried:

  • arranging knowledge expressed types.
  • using option processing methods mentioned (flatmap, getorelse etc), , none of them fit elegantly.

it's convenient throwaway / interactive code (repl, worksheets etc).


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -