I am reading the book "Professional F# 2.0" The author shows the following code
let a string : option = None
if a.IsNone then
System.Console.WriteLine("a is none")
else
System.Console.WriteLine("a is some");;
then says
"this makes the use of Option vastly superior to the use of null and goes a long way towards removing a significant source of exceptions thrown at runtime"
ok. so I write
System.Console.WriteLine(a.GetType());;
And I get
System.NullReferenceException: Object reference not set to an instance of an object. at System.Object.GetType() at .$FSI_0008.main@() Stopped due to error
And I am like 'un!!!"
How is really doing a
if a.isSome then
do bla bla
any different from
if a != null then
do bla bla
So I don't see how is the programmer being saved from NullPointers
PS: NullPointerException has caused me lot of grief in the past.