What do we think about this: ```nuller = ()=>;...
# lucee
a
What do we think about this:
Copy code
nuller = ()=>; // CF: fine; Lucee: Syntax Error, Invalid Construct on line 2

writeDump([isNull(nuller())])
https://trycf.com/gist/a2d193ecb21c454dbe13d932c6c99c61/lucee5?theme=monokai And, yes, I did actually write code like that. Well actually it was
nullValue = (()=>)()
, but it's a similar issue.
m
Do you know what other languages support lambda's in that manner. empty I know JavaScript didn't when I just tried.
Copy code
nuller=()=>; /*errors*/
nuller=()=>{}; /* doesn't error */
nuller=()=>log; /* doesn't error */
d
@Adam Cameron That syntax smells fishy to me. Why not just use
javaCast("null", "")
? It works in all flavors/versions of CF just fine and I think it's a lot easier to understand.
b
I think I have a ticket for that
I've written that same code when testing null across engines since ACF doesn't have the
nullValue()
BIF
a
@dswitzer oh I was not using the code. It just cropped up as I was messing around. I am fully aware of
javaCast
and that's what I actually used; just I have always found it dead clunky, and there's precedent about the place for using a
nuller
function to effect the same thing. That got me thinking about exactly how much of the arrow function I actually needed to pull it off, as it were. And @Michael Schmidt yeah, I started with the second of those options, but then wondered why I should need the function body when a short-hand arrow function simply returns the value of the expression. And nothing is an expression (of sorts). I can see no reason why it oughtn't work, even if it's not exactly terribly clear code. Cheers for the ticket URL, @bdw429s. And TIL
nullValue
is a thing in Lucee's CFML. I might use that instead of the
javaCast
approach. No need for cross-compat in my situation.
b
Uh oh, time for you to read all the Lucee release notes since Railo 2 🤣
😂 1
a
in my defence... I have only been using Lucee for 2yrs. Ahem.
[insert cringe emoji here]
z
modern syntax is ugly AF
a
z