diff options
| author | mo khan <mo@mokhan.ca> | 2013-08-28 07:20:13 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2013-08-28 07:20:13 -0600 |
| commit | db1191ec0e7305d684383f8974e2fa437f77ad5a (patch) | |
| tree | 5e27b197dff849d22d8e1f50eb75aa499b16bd06 /code/snippets/cow.rb | |
Diffstat (limited to 'code/snippets/cow.rb')
| -rw-r--r-- | code/snippets/cow.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/code/snippets/cow.rb b/code/snippets/cow.rb new file mode 100644 index 0000000..f7d85d4 --- /dev/null +++ b/code/snippets/cow.rb @@ -0,0 +1,12 @@ +arr = [1,2,3] + +fork do + # At this point the child process has been initialized. + # Because of CoW the arr variable hasn't been copied yet. + arr << 4 + # The above line of code modifies the array, so a copy of + # the array will need to be made for this process before + # it can modify it. The array in the parent process remains + # unchanged. +end + |
