I'm trying to write a script for hubot to get player statistics for a game, however I am having some trouble with list comprehension.
Here's my code
listings = []
listings =
(for player in players
request "http://pwa.wp3.pl/curvefever/?player=" + player , (err, res, body)->
$ = cheerio.load(body)
msg.send "Hello, world!1"
{name: $('b').slice(0).eq(0).text().toLowerCase(), rank: parseInt($('td').slice(37).eq(0).text(),10)})
msg.send "Hello, world!2"
for player of listings
msg.send "Hello, world!3"
msg.send player.name + " " + player.rank
when running this I get "Hello, world!2" followed by several "Hello, world!1" and no "Hello, world!3" as listings is (presumably) empty.
The script works when I do msg.send
instead of trying to capture the listings in an array, however I'd like to sort the listings based on rank too.