Skip to content

Commit

Permalink
Return instead of wrapping code in a big if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
3rd-Eden committed Jun 19, 2011
1 parent dea5234 commit 32bf6fe
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions examples/chat/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,10 @@ io.sockets.on('connection', function (socket) {
});

socket.on('disconnect', function () {
delete nicknames[socket.nickname];
if (!socket.nickname) return;

if (socket.nickname) {
socket.broadcast.emit('announcement', socket.nickname + ' disconnected');
socket.broadcast.emit('nicknames', nicknames);
}
delete nicknames[socket.nickname];
socket.broadcast.emit('announcement', socket.nickname + ' disconnected');
socket.broadcast.emit('nicknames', nicknames);
});
});

0 comments on commit 32bf6fe

Please sign in to comment.