iconfu iconfu iconfu is the world's largest collection of free, open-source icons and it comes with a handy image editor, so you can tweak icons to suit your needs exactly or even draw your own from scratch
invert blue resize move up verbose drawmode lighter previews remove swap animator library library draw shift up make a copy large editor explorer your icon contract agreement tag

14 June 2007

Why I Like Ruby

I need to see if a property of the last n elements of a collection ("moves") is nil, where n is the number of players:

 moves.last(players.size).collect(&:piece).compact.size == 0

I don't know how to do this so readably in any number of lines of code in java:

  • initialise a counter to zero
  • from (moves.size - 1) down to (moves.size - (players.size + 1)), inspect "piece" property
  • if it's not null, increment the counter
  • counter == 0