Jump to content
Mike Torrettinni

Manage overloaded IfThen functions

Recommended Posts

1 hour ago, Lars Fosdal said:

// Type inference makes the <T> argument to When optional when the parameters are the same type

This is pretty flaky mind you. Sometimes type inference works, sometimes it doesn't and you have to be explicit. It is something that may have improved in more recent releases, but IIRC some issues remain.

  • Like 1

Share this post


Link to post

The Byte example shows that flakiness, but it does seem to work well in 10.4.1 - also with regards to Error Insight. 

Share this post


Link to post

In the exactly same situation (using extra unit for just one 3-lined function annoys me like hell) I ended up with most trivial solution - I named my functions `IfTh`.

Edited by Fr0sT.Brutal
  • Like 1

Share this post


Link to post
On 12/18/2020 at 12:31 AM, Fr0sT.Brutal said:

In the exactly same situation (using extra unit for just one 3-lined function annoys me like hell) I ended up with most trivial solution - I named my functions `IfTh`.

Mine - in use for the last 20 years - is named iif. Yes, I was a FoxPro user in the 1990s! I was looking at something in one of my programs a few weeks back and realised it was there to save space when saving to floppy disk. If there's such a thing as a code archaeologist they could have a great time with my codebase.

Share this post


Link to post
On 12/19/2020 at 1:28 PM, TonyB said:

Mine - in use for the last 20 years - is named iif

This one is nice as well, SQL-style

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×