Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This can be written like this too:

  keydown_action_map = 
        37: 'pan_left'
        38: 'pan_up'
        39: 'pan_right'
        40: 'pan_down'
        189: 'zoom_out'
        187: 'zoom_in'

  document.addEvent 'keydown', (event) ->
    action = keydown_action_map[event.keyCode]
    game_pieces.each game_piece[action], game_piece
If you can write terse code in JS you can write it even more terse way in CS.


Where "more terse" means "removing a useful keyword and replacing parens by spaces".

Not exactly impressive (and coffeescript's symbolless maps read horribly badly, imo).


Which keyword is useful? Var? CS will put it back at compile time, don't worry. And it will do it in more consistent manner than many coders will manually. I have no problems with symbolless maps, and CS will save your ass from being bitten by IE because of stray comma.


I protect my ass with VIM -- any "IDE" likely has an equivalent.

  au BufWrite *.js mark` | silent!%s/,\(\_s*[}\]]\)/\1/g | norm``


> Which keyword is useful? Var?

Yes.

> CS will put it back at compile time, don't worry.

May I ask why you're assuming I'm a moron, exactly?

> And it will do it in more consistent manner than many coders will manually.

I don't know who your coders are, but you should fire them.

> CS will save your ass from being bitten by IE because of stray comma.

Yep, confirmed, and you should probably fire yourself as well.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: