As Stephen pointed out by using the above solution fontweight will contain a function.
For some reason I did not come up with an even simpler solution first:
No it isn't.EDIT: Sorry you are right it is a function, for some reason I was so focused on the Arrow operator on PHP that I wanted to do something similar but did not come up with the even simpler solution.
I will update my post.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You can easily replicate match behavior (actually not, see edited version):
Edit
As Stephen pointed out by using the above solution fontweight will contain a function.
For some reason I did not come up with an even simpler solution first:
You can also do it without having to store the object in "match":
And if you need a default value you can achieve it like that:
Thatβs very clever π
It reminds me of the guards expression in Haskell.
The issue I can see with this is now the variable fontweight is a function is it not?
No it isn't.EDIT: Sorry you are right it is a function, for some reason I was so focused on the Arrow operator on PHP that I wanted to do something similar but did not come up with the even simpler solution.I will update my post.