Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def parse_mode(str)
- mode, modes = true, ["+","-"]
- str.split("").inject([]) do |r,c|
- mode = (c=="+") ? true : (c == "-" ? false : mode)
- mode ? r << c : r.subtract_once(c) unless(modes.include?(c)) ; r
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment