Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Option(value) and Some(value)

Tags:

scala

I am new to scala !

My question is, if there is case class that contains a member

myItem:Option[String] 

When i construct the class, i need to wrap the string content in:

Option("some string") 

OR

Some("some string") 

Is there any difference ?

Thanks!

like image 939
ilansch Avatar asked Apr 07 '14 09:04

ilansch


People also ask

Is the option value the same as the price?

Key Takeaways. Options prices, known as premiums, are composed of the sum of its intrinsic and time value. Intrinsic value is the price difference between the current stock price and the strike price. An option's time value or extrinsic value of an option is the amount of premium above its intrinsic value.

What do you mean by option value?

In cost–benefit analysis and social welfare economics, the term option value refers to the value that is placed on private willingness to pay for maintaining or preserving a public asset or service even if there is little or no likelihood of the individual actually ever using it.

Is Option Value and Premium same?

Key Takeaways. The option premium is the total amount that investors pay for an option. The intrinsic value of an option is the amount of money investors would get if they exercised the option immediately.

What gives an option value?

Option value, also known as option premium, is really just made up of two contributing factors - intrinsic & extrinsic value. These values change based on three inputs: strike price in relation to the stock price, implied volatility, and time until expiration. That's it!


Video Answer


1 Answers

If you look into Scala's sources you'll notice that Option(x) just evaluates x and returns Some(x) on not-null input, and None on null input.

I'd use Option(x) when I'm not sure whether x can be null or not, and Some(x) when 100% sure x is not null.

One more thing to consider is when you want to create an optional value, Some(x) produces more code because you have to explicitly point the value's type:

val x: Option[String] = Some("asdasd") //val x = Option("asdasd") // this is the same and shorter 
like image 115
serejja Avatar answered Oct 18 '22 17:10

serejja