Created
October 9, 2016 19:51
-
-
Save jaeming/a9fc6bf9b758a0563ed4904377f7e719 to your computer and use it in GitHub Desktop.
split one liner
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
def split(str, key) | |
(list, word = [], '') and str.chars.to_a.map { |i| i == key ? (list << word and word = '') : word << i } and list << word | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment