Skip to content

Instantly share code, notes, and snippets.

@ffbit
Last active December 10, 2015 00:58
Show Gist options
  • Select an option

  • Save ffbit/4354762 to your computer and use it in GitHub Desktop.

Select an option

Save ffbit/4354762 to your computer and use it in GitHub Desktop.
CoffeScript Splats example
leaderboard = ["ERC", "AMY", "BOB", "AAA", "STU"]
[winner, others..., loser] = leaderboard
console.log """
First place: #{winner}.
Last place: #{loser}.
"""
// Generated by CoffeeScript 1.4.0
(function() {
var leaderboard, loser, others, winner, _i,
__slice = [].slice;
leaderboard = ["ERC", "AMY", "BOB", "AAA", "STU"];
winner = leaderboard[0],
others = 3 <= leaderboard.length ? __slice.call(leaderboard, 1, _i = leaderboard.length - 1) : (_i = 1, []),
loser = leaderboard[_i++];
console.log("First place: " + winner + ".\nLast place: " + loser + ".");
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment