ruby-uebungen/Assignment_036/solution/readme.md

27 lines
287 B
Markdown

# Lösung: Eigenclass einer Klasse
```ruby
class Numeric
class << self
def to_binary(n)
n.to_s(2)
end
end
end
puts Numeric::to_binary(47)
```
Alternative Lösung:
```ruby
class << Numeric
def to_binary(n)
n.to_s(2)
end
end
puts Numeric::to_binary(47)
```