DEV Community

Discussion on: Daily Challenge #34 - WeIrD StRiNg CaSe

Collapse
 
hanachin profile image
Seiei Miyagi
def to_weird_case(s) s.split(' ').map { @1.chars.map.with_index
 { @2.even? ? @1.upcase : @1.downcase }.join }.join(' ') end
Collapse
 
andy profile image
Andy Zhao (he/him)

Ah I tried map_with_index but that's not a method. Did not know there was a .map.with_index!

Collapse
 
hanachin profile image
Seiei Miyagi

I'm glad to hear that. Enumerable has so many methods, which is useful but I take a little bit time to remember them.