Skip to content

Instantly share code, notes, and snippets.

@capitalist
Created September 22, 2008 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save capitalist/12021 to your computer and use it in GitHub Desktop.
Save capitalist/12021 to your computer and use it in GitHub Desktop.
a = %w(a b c d)
a.inject([]) {|arr,e| arr[-1]=='a' ? arr.insert(-2,e) : arr.push(e)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment