Re:CoffeeScript: less typing, bad readability
by j-kidd on Monday September 17, 2012 @06:39PM
(#4535286)
May I ask what are the use cases for maps like that? I don't think I have ever needed one myself.
[ Parent
| on HN ]
Re:CoffeeScript: less typing, bad readability
by lowboy on Monday September 17, 2012 @06:58PM
(#4535343)
I have situations like this quite frequently where I need to turn vars into members of an object:
title = getTheTitle()
img = (shouldWeGetImg) ? getImg() : "placeholder.jpg"
body = ...
# 8 lines of code to define body, some that reference title and img
# this:
obj = { title, img, body }
# instead of:
obj = {title: title, body: body, img: img}