Skip to content

Instantly share code, notes, and snippets.

@jaeming
Created October 9, 2016 19:51
Show Gist options
  • Save jaeming/a9fc6bf9b758a0563ed4904377f7e719 to your computer and use it in GitHub Desktop.
Save jaeming/a9fc6bf9b758a0563ed4904377f7e719 to your computer and use it in GitHub Desktop.
split one liner
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