Alternative join and split in Ruby

Join

          >> %w(tic tac toe) * "-" 
          => "tic-tac-toe" 
          

Split

          >> "tic-tac-toe" / "-" 
          => ["tic", "tac", "toe"]
          

Unfortunately, for split you’ll need this of course:

          class String
            alias / :split
          end
          

;)

« Home | This article was published on July 09, 2008.

Comments

Any thoughts?