Created
January 30, 2011 19:22
-
-
Save amuino/803146 to your computer and use it in GitHub Desktop.
Example of the weird magic that makes plagelao's kata work without working :-)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open irb on the kata directory | |
ruby-1.9.2-p0 > require "./string_calculator_spec" | |
=> true | |
ruby-1.9.2-p0 > s = Separator.new("//[**][+++]\n") | |
=> /,| | |
|["**|+++"]/ | |
ruby-1.9.2-p0 > #Ojo al último patrón! Eso matchea cualquier caracter dentro de [] | |
ruby-1.9.2-p0 > "1++2***3".split(s) | |
=> ["1", "", "2", "", "", "3"] | |
ruby-1.9.2-p0 > #Separa el primer símbolo, procesa el resto como cadena vacía | |
ruby-1.9.2-p0 > "10++20***30".split(s) | |
=> ["10", "", "20", "", "", "30"] | |
ruby-1.9.2-p0 > #Idem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment