This is a pretty simple thing, and I’m sure someone will disagree with me, but it would be a really nice quality of life improvement if Function types implicitly cast to Bools.
This works with objects, of course. Compare this:
<pre class=”lang:monkey decode:true “>Class FooBar
Field entity:Entity
Method Update()
If entity
entity.Update()
Endif
End
End
And this:
<pre class=”lang:monkey decode:true”>Class FooBar
Field updateCallback:Void()
Method Update()
If updateCallback <> Null ‘ doesn’t work without “<> Null”
updateCallback()
Endif
End
End
It seems silly that I have to explicitly tell the compiler what I mean, since what it means for a function pointer to be “truthy” is pretty well understood.