ruby-uebungen/Assignment_037/solution/readme.md

15 lines
522 B
Markdown
Raw Normal View History

2023-05-25 17:47:19 +02:00
# Lösung: Eigenclass eines Objektes
2023-05-23 09:19:31 +02:00
<div style="border: 1px solid grey;"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></div>```ruby
2023-05-25 17:47:19 +02:00
s1 = "Hallo"
s2 = "Welt"
2023-05-23 09:19:31 +02:00
2023-05-25 17:47:19 +02:00
class << s2
def to_leet
self.tr('aeiou', '43107')
2023-05-23 09:19:31 +02:00
end
end
2023-05-25 17:47:19 +02:00
puts s2.to_leet
```