What does the 'Constant' modifier do to cause this behavior?
Ältere Kommentare anzeigen
For the following classes:
classdef Outer1 < handle
properties (Constant)
inner_inst = Inner();
end
end
classdef Outer2 < handle
properties (Constant)
inner_inst = Inner();
end
end
classdef Inner < handle
properties
innermost_inst = Innermost();
end
end
classdef Innermost < handle
properties (Constant)
innermost_int = 5;
end
end
I have instantiated variables as follows:
out1a = Outer1();
out1b = Outer1();
out2a = Outer2();
out2b = Outer2();
Then I tried these comparisons (with the result shown next to it):
out1a.inner_inst == out1b.inner_inst: true
out1a.inner_inst == out2b.inner_inst: false
out1a.inner_inst.innermost_inst == out1b.inner_inst.innermost_inst: true
out1a.inner_inst.innermost_inst == out2b.inner_inst.innermost_inst: true
I understand why the top three lines produce their results, but what causes the last line to be true? This same code but with static members instead of Constant produces false for this last comparison in Java.
public class Outer1 {
public static Inner inner_inst = new Inner();
}
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Handle Classes finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!