Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update 002-covers-vs-classes.md

  • Loading branch information...
commit c55b29776b1f30ccae51fec3d02c8d816e10128b 1 parent 460c639
@cdrubin cdrubin authored
Showing with 6 additions and 8 deletions.
  1. +6 −8 002-covers-vs-classes.md
View
14 002-covers-vs-classes.md
@@ -1,4 +1,3 @@
-
When to use covers and classes
==============================
@@ -33,18 +32,17 @@ Classes are by-references. Which means every object is a reference. Doing that:
}
answer := Number new(42)
- modify(answer) // does nothing
+ modifyRef(answer) // does nothing
modifyInside(answer)
~~~
-What happens in 'modifyRef' is that we change what 'n' refers to in the
-modifyRef function. It doesn't modify what 'n' referred to in the first place,
-in this case the 'answer' variable we gave it as argument. So 'modifyRef' has
+What happens in 'modifyRef' is that we change the value of the parameter 'n'.
+The code does not modify what 'n' was a reference to in the first place.
+In the example above the variable 'answer' is given as the argument and 'modifyRef' has
no effect at all on 'answer'.
-However, in 'modifyInside', we modify the content of what 'n' refers to.
-Since 'n' refers to 'answer', the content of 'value' is modified, ie its value
-is changed to -1
+However, in 'modifyInside', we actually modify the content of what 'n' refers to.
+Since 'n' refers to 'answer', the code will modify its member 'value' and set it to -1.
### Covers ###
Please sign in to comment.
Something went wrong with that request. Please try again.