Add Data.define examples to NEWS [ci skip]

This commit is contained in:
Takashi Kokubun 2022-12-15 11:49:55 -08:00
Родитель c0b14e128f
Коммит 2ae0e27a69
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 6FFC433B12EE23DD
1 изменённых файлов: 8 добавлений и 0 удалений

Просмотреть файл

@ -187,6 +187,14 @@ Note: We're only listing outstanding class updates.
similar to Struct and partially shares an implementation, but has more
lean and strict API. [[Feature #16122]]
```ruby
Measure = Data.define(:amount, :unit)
distance = Measure.new(100, 'km') #=> #<data Measure amount=100, unit="km">
weight = Measure.new(amount: 50, unit: 'kg') #=> #<data Measure amount=50, unit="kg">
weight.amount #=> 50
weight.amount = 40 #=> NoMethodError: undefined method `amount='
```
* Encoding
* Encoding#replicate has been deprecated and will be removed in 3.3. [[Feature #18949]]