Hi.
I'm trying to rewrite the samples from "node.js: up and running" into LiveScript as a practice.
However, I found array.splice somewhat ugly:
I'd like to write it somewhat python-like, say,
(Ugly:)
client.on \end !->
clientList.splice clientList.indexOf(client), 1
14 client.on('end', function(){
15 clientList.splice(clientList.indexOf(client), 1);
16 });
(Better but doesn't work:)
client.on \end !->
clientList = [i for i in clientList when i isnt client]
14 client.on('end', function(){
15 var clientList, res$, i$, len$, i; // Wrong! clientList should not be here
16 res$ = [];
17 for (i$ = 0, len$ = clientList.length; i$ < len$; ++i$) {
18 i = clientList[i$];
19 if (i !== client) {
20 res$.push(i);
21 }
22 }
23 clientList = res$;
24 });
How should I make it work?
Thanks!