/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/ruby/ruby-511-102-006/main.rb
33 строки
551 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
class Product def initialize(name, price) @name = name @price = price end # Геттеры def name @name end def price @price end # Сеттеры def name=(new_name) @name = new_name end def price=(new_price) @price = new_price if new_price >= 0 end end product = Product.new("Книга", 500) puts product.name # Книга puts product.price # 500 product.name = "Новая книга" product.price = 600 puts product.name # Новая книга puts product.price # 600