salted
05/01/2025, 4:54 PMbdw429s
05/01/2025, 6:10 PMbdw429s
05/01/2025, 6:11 PMbdw429s
05/01/2025, 6:11 PMsalted
05/01/2025, 6:20 PMsalted
05/01/2025, 6:22 PMvar obj = etc
Obj.read(obj2)
Obj.otherMethod(somethingelse)
bdw429s
05/01/2025, 6:23 PMobj
only lives once in the heap, but there are 1 or more variable references pointing to itbdw429s
05/01/2025, 6:24 PMobj
is specifically an immutable class, any updates to it will be "seen" by any of the variable references pointing to itsalted
05/01/2025, 6:24 PMsalted
05/01/2025, 6:24 PMsalted
05/01/2025, 6:25 PMbdw429s
05/01/2025, 6:26 PMbdw429s
05/01/2025, 6:27 PMBill Nourse
05/01/2025, 6:30 PMsalted
05/01/2025, 6:31 PMbdw429s
05/01/2025, 6:31 PMsalted
05/01/2025, 6:31 PMBill Nourse
05/01/2025, 6:31 PMsalted
05/01/2025, 6:32 PMsalted
05/01/2025, 6:32 PMbdw429s
05/01/2025, 6:32 PMwidget = new widget();
widget.disable();
There's no need for disable()
to return anything. It simply modifies the internal state of the widget instance.bdw429s
05/01/2025, 6:33 PMBill Nourse
05/01/2025, 6:34 PMbdw429s
05/01/2025, 6:34 PMbdw429s
05/01/2025, 6:34 PMbdw429s
05/01/2025, 6:35 PMBill Nourse
05/01/2025, 6:35 PMBill Nourse
05/01/2025, 6:37 PMsalted
05/01/2025, 7:00 PMbdw429s
05/01/2025, 7:04 PMmodify()
method on the something
class mutates the passed obj
?salted
05/01/2025, 7:22 PMsalted
05/01/2025, 7:22 PMsalted
05/01/2025, 7:23 PMsalted
05/01/2025, 7:23 PMsalted
05/01/2025, 7:24 PMsalted
05/01/2025, 7:26 PMBK BK
05/04/2025, 11:46 AM"... an obj was modified without assigning it to a var as in instantiate an obj, pass it to another method and modify it afterwards all without assigning any of those operations to a var. Not sure if I'm being clear there lol"
I suppose the following code illustrates what you mean. If so, then the explanation is the one that @bdw429s gave, namely:
"...unless obj is specifically an immutable class, any updates to it will be "seen" by any of the variable references pointing to it"
<!--- testpage.cfm --->
<cfscript>
obj = new Person(email="<mailto:FirstName@first.domain.com|FirstName@first.domain.com>");
writedump(var=obj, label="Person object upon instantiation");
caller1 = new Caller1();
caller1.modify(obj);
writedump(var=obj, label="Person object after caller1.modify() call");
caller2 = new Caller2();
caller2.modify(obj);
writedump(var=obj, label="Person object after caller2.modify() call");
</cfscript>
<!--- Person.cfc: mutable! --->
<cfcomponent accessors="true">
<cfproperty name="email">
</cfcomponent>
<!--- Caller1.cfc --->
<cfcomponent>
<cffunction name="modify">
<cfargument name="inputObject">
<cfset arguments.inputobject.setEmail("<mailto:SecondName@second.domain.com|SecondName@second.domain.com>")>
</cffunction>
</cfcomponent>
<!--- Caller2.cfc --->
<cfcomponent>
<cffunction name="modify">
<cfargument name="inputObject">
<cfset arguments.inputobject.setEmail("<mailto:ThirdName@third.domain.com|ThirdName@third.domain.com>")>
</cffunction>
</cfcomponent>