1
0
Fork 0
mirror of https://github.com/ms-ati/docile synced 2023-03-27 23:21:52 -04:00

Clarify example of immutable DSL object in README

This commit is contained in:
Marc Siegel 2013-07-29 03:07:41 -04:00
parent ecb259db1f
commit 514e3a409c

View file

@ -166,11 +166,16 @@ order to enforce [immutability](http://en.wikipedia.org/wiki/Immutable_object).
Wouldn't it be great if we could just treat these methods as a DSL as well?
```ruby
with_immutable_string("I'm immutable!".freeze) do
s = "I'm immutable!".freeze
with_immutable_string(s) do
reverse
upcase
end
#=> "!ELBATUMMI M'I"
s
#=> "I'm immutable!"
```
No problem, just define the method `with_immutable_string` like this: