You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we know in Javascript this bug can be solved with a self executing function with the
loop variables passed as arguments to the nested function, which looks horrible...
I hoped that Coffee solved this and we could do it like below:
Note the 'then' after the for loop, as I have to use it now, doesn't make sense to me. It looks almost accidental that the compiler accepts this, of course I can skip 'then' and move the
'do ->' to the line below, but that only adds another redundant line and indentation
The text was updated successfully, but these errors were encountered:
If that's the real code, I have to say that it smells, badly.
It doesn't even do well for an SSCE Nevertheless, I think I have an answer for you...
An idiomatic approach is to use do, like this:
show= {}
for method in [ 'upper', 'lower' ]
show[method] =do (method) ->return ( text ) ->text=text.toUpperCase() if method is'upper'text=text.toLowerCase() if method is'lower'console.log text
show.upper( 'big!' ) # big!
There you write the anonymus function fix that I hate so much. Please read first before you reply, the first two lines of my request tell enough to make your 'idiomatic' solution for 'me' completely pointless.
Your answer is even less ssce compliant as there is a bug in it and fails if executed. And no, this is not 'real code'... I made this up for the example. Maybe I can please you to change the used names to foo and bar?
we know in Javascript this bug can be solved with a self executing function with the
loop variables passed as arguments to the nested function, which looks horrible...
I hoped that Coffee solved this and we could do it like below:
but, disappointment, the Javascript bug persists..
for now I still can't find another/better way than this:
Note the 'then' after the for loop, as I have to use it now, doesn't make sense to me. It looks almost accidental that the compiler accepts this, of course I can skip 'then' and move the
'do ->' to the line below, but that only adds another redundant line and indentation
The text was updated successfully, but these errors were encountered: