def reverser(s) /(.*) (.*)/ =~ s "#{$2} #{$1}" end puts reverser("Ruby Programmierer")
Alternative Lösung:
def reverser(s) m = /(.*) (.*)/.match(s) "#{m[2]} #{m[1]}" end puts reverser("Ruby Programmierer")