The question is simple and. although it is obvious the answer, I had to face a strange situation where the fsharp told me something a bit strange. Here's the story:
The question is: Does F# automatically make every type inherit the Object
class? I suppose YES and I am certain of this because there would be so many complications if that were not the case.
But here's a fact. I was writing this piece of code:
type MyType =
val myval: int
override self.ToString = "Hello MyType"
Well, fsharp compiler told me it is not correct using overrid because he does not find any method called ToString
to override. I so compiled this code:
type MyType =
val myval: int
member self.ToString = "Hello MyType"
And everything worked fine.
mmmmmm What's happening???
Isn't FSharp supposed to inherit every object from Object
?