ruby-uebungen/Assignment_041/solution/readme.md

17 lines
703 B
Markdown
Raw Normal View History

2023-05-25 17:47:19 +02:00
# Lösung: Struct
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
# 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
```