|
|
|
|
|
by geocar
4257 days ago
|
|
The view automatically gets updated whenever a gets updated. Every time you change a (directly or indirectly), then c will automatically get updated. Doing this generally in Ruby I think is impossible, but you might be able to get close if all your objects are based on ActiveModel::Dirty |
|
Not so much. At least with views over most Enumerables, its quite possible in Ruby -- that's the whole reason that Enumerable::Lazy exists.
The existing File class doesn't quite support it because of the way its iterators are implemented (particularly, they are one way) but the class is easily extended to allow it, e.g.:
Then you can create a synced view that has the character positions of the newlines in a file like this: