ruby-uebungen/Assignment_035/solution
Thomas Smits 25d5ac7ffd Initial commit 2023-05-23 09:19:31 +02:00
..
readme.md Initial commit 2023-05-23 09:19:31 +02:00

readme.md

Lösung: Reguläre Ausdrücke: Matching





























































```ruby def reverser(s) /(.*) (.*)/ =~ s "#{$2} #{$1}" end

puts reverser("Ruby Programmierer")


Alternative Lösung:

```ruby
def reverser(s)
  m = /(.*) (.*)/.match(s)
  "#{m[2]} #{m[1]}"
end

puts reverser("Ruby Programmierer")