My first F# day. If I have this:
let cat = Animal()
Now how do I check at later stage if cat
is
Animal
?
In C#
bool b = cat is Animal;
In F#?
My first F# day. If I have this:
let cat = Animal()
Now how do I check at later stage if cat
is
Animal
?
In C#
bool b = cat is Animal;
In F#?
For demonstration only (don't define an
is
function):@ildjarn deserves the credit here for answering first, but I'm submitting the answer here so it can be accepted.
The F# equivalent of the C#
is
keyword is:?
. For example:I know I'm late. If you try to test the type of a collection in fsi with :? it will give an error, if the item types do not match. E.g.
Wrapping in a function like Daniels is<'T> works.