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:
parent
ecb259db1f
commit
514e3a409c
1 changed files with 6 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue