“Pass-by-value” is one of the most confusing topic for me until I read this topic from OCA book. This topic is explained very well, I could understand some points which was unclear for me.
I have some confused notes about this topic and I would like to share it.
1. On page 188, the latest row Don’t we pass num variable instead of 5 or I think wrong? As this
2. On page 191, line #5 of example The note which is written after comment in line 5 ( // 1 ) is confused me. I understand such comment show output which the same line return. Line 5 returns 2 but we know that this code doesn’t change the value of number. Maybe authors write value of number variable in it so they want to show that value of number variable isn’t change in that line, so it is explained the last paragraph of section.
3. On page 191, the last paragraph of section, fifth sentence: Maybe numbers should be number.
Sorry for my English, maybe I don’t say my opinion correctly.
Mushfiq Mammadov wrote:1. On page 188, the latest row
The actual code in the book is correct, but newNumber(5); isn't an example of pass-by-value. Should indeed beto have a true illustrative pass-by-value example
Mushfiq Mammadov wrote:2. On page 191, line #5 of example
I agree with you on this one: the comment behind the statement could indeed be confusing, certainly for the method invocations because you have the value of the parameter and you have the return value (which might be ignored). But there is just one number. If you have a look at the code (and/or read the explanation in the section), it's obviously the value of the variable used in the statement. Once you know this, these comments are not confusing anymore, but at a 1st glance it probably could be. And because the code is well explained in the section directly below the code, these line comments could even be dropped. Or for more clarity could be a little bit extended toor even more verboseBoth indicate the value of the variable before and after this statement. Just a suggestion, don't know if it really improves the understanding of the comments in the code snippet
Mushfiq Mammadov wrote:3. On page 191, the last paragraph of section, fifth sentence:
Not maybe, but definitely
Mushfiq Mammadov wrote:Sorry for my English, maybe I don’t say my opinion correctly.
I think I understood everything correctly after a 1st read, so no problem here