i have string of length n
, want split equal parts of length l
(assuming last part might shorter).
what came is:
string.split('').each_slice(l).map(&:join)
but toooooo long (and ugly, honest.) unable read documentation properly, or there no built-in method perform task?
what this?
string.scan(/.{,#{l}}/)
Comments
Post a Comment