/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/ruby/ruby-511-1-007/main.rb
22 строки
426 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
class FlexibleHash def initialize @store = {} end def method_missing(name, *args, &block) if name.to_s.end_with?('=') key = name.to_s[0..-2].to_sym @store[key] = args.first else @store[name] end end def respond_to_missing?(name, _include_private = false) name.to_s.end_with?('=') || @store.key?(name.to_sym) end end h = FlexibleHash.new h.name = "Ruby" h.name # => "Ruby"