ruby-uebungen/Assignment_034/solution/readme.md

16 lines
254 B
Markdown
Raw Normal View History

2023-05-25 17:47:19 +02:00
# Lösung: Klasse dynamisch erzeugen
2023-05-23 09:19:31 +02:00
2023-05-25 17:49:42 +02:00
```ruby
2023-05-25 17:47:19 +02:00
def create_class(super_class)
Class.new(super_class) do
def who_am_i
puts "Ich bin ein Kind von #{self.class.superclass}"
end
end
2023-05-23 09:19:31 +02:00
end
2023-05-25 17:47:19 +02:00
Test = create_class(Object)
t = Test.new
t.who_am_i
2023-05-23 09:19:31 +02:00
```