ruby-uebungen/Assignment_041/solution/readme.md

18 lines
341 B
Markdown
Raw Permalink Normal View History

2023-05-25 17:47:19 +02:00
# Lösung: Struct
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
# Klasse (sic!) über Struct erzeugen
Studierender = Struct.new(:vorname, :nachname, :geboren, :matrikel, :fakultaet)
2023-05-23 09:19:31 +02:00
2023-05-25 17:47:19 +02:00
# KLasse noch einmal öffnen und Methode hinzufügen
class Studierender
def to_s
matrikel
2023-05-23 09:19:31 +02:00
end
end
2023-05-25 17:47:19 +02:00
peter = Studierender.new('Peter', 'Meier', '15.03.1998', '123222', 'I')
puts peter
2023-05-23 09:19:31 +02:00
```