<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Getter &#038; Setter Inheritance Gotcha	</title>
	<atom:link href="https://jessewarden.com/2005/05/getter-setter-inheritance-gotcha.html/feed" rel="self" type="application/rss+xml" />
	<link>https://jessewarden.com/2005/05/getter-setter-inheritance-gotcha.html</link>
	<description>Software &#124; Fitness &#124; Gaming</description>
	<lastBuildDate>Wed, 04 May 2005 16:30:58 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>
		By: JesterXL		</title>
		<link>https://jessewarden.com/2005/05/getter-setter-inheritance-gotcha.html/comment-page-1#comment-2587</link>

		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Wed, 04 May 2005 16:30:58 +0000</pubDate>
		<guid isPermaLink="false">http://jessewarden.com/?p=795#comment-2587</guid>

					<description><![CDATA[This works:
&lt;code&gt;class SuperClass
{
	private var _foo:String = &#039;bar&#039;;
	
	public function get foo():String
	{
		return _foo;
	}
	
	public function set foo(val:String):Void
	{
		_foo = val;
	}
	
	function SuperClass()
	{
	}
}

class SubClass extends SuperClass
{
	function SubClass()
	{
	}
}

var o:SubClass = new SubClass();
trace(o.foo); // bar
o.foo = &#039;cow&#039;;
trace(o.foo); // cow&lt;/code&gt;

This, however, does not when you try to set it because it assumes it&#039;s read-only (really, it doesn&#039;t compile because it&#039;s looking for a function value):

&lt;code&gt;class SubClass extends SuperClass
{
	public function get foo():String
	{
		return _foo;
	}
	
	function SubClass()
	{
	}
}&lt;/code&gt;

We had a situation at work where the getter wasn&#039;t present, but the setter was and you always got undefined. I can&#039;t duplicate it now, so will have to get back to this.


]]></description>
			<content:encoded><![CDATA[<p>This works:<br />
<code>class SuperClass<br />
{<br />
	private var _foo:String = 'bar';</p>
<p>	public function get foo():String<br />
	{<br />
		return _foo;<br />
	}</p>
<p>	public function set foo(val:String):Void<br />
	{<br />
		_foo = val;<br />
	}</p>
<p>	function SuperClass()<br />
	{<br />
	}<br />
}</p>
<p>class SubClass extends SuperClass<br />
{<br />
	function SubClass()<br />
	{<br />
	}<br />
}</p>
<p>var o:SubClass = new SubClass();<br />
trace(o.foo); // bar<br />
o.foo = 'cow';<br />
trace(o.foo); // cow</code></p>
<p>This, however, does not when you try to set it because it assumes it&#8217;s read-only (really, it doesn&#8217;t compile because it&#8217;s looking for a function value):</p>
<p><code>class SubClass extends SuperClass<br />
{<br />
	public function get foo():String<br />
	{<br />
		return _foo;<br />
	}</p>
<p>	function SubClass()<br />
	{<br />
	}<br />
}</code></p>
<p>We had a situation at work where the getter wasn&#8217;t present, but the setter was and you always got undefined. I can&#8217;t duplicate it now, so will have to get back to this.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jared Rypka-Hauer		</title>
		<link>https://jessewarden.com/2005/05/getter-setter-inheritance-gotcha.html/comment-page-1#comment-2586</link>

		<dc:creator><![CDATA[Jared Rypka-Hauer]]></dc:creator>
		<pubDate>Wed, 04 May 2005 08:46:29 +0000</pubDate>
		<guid isPermaLink="false">http://jessewarden.com/?p=795#comment-2586</guid>

					<description><![CDATA[I was going to ask if Flash had a super scope... I know CF does, but I also know that there are similarities and differences between the two platforms... and the two can be pretty stark.

But if you can use the super scope, you&#039;re not overwriting your parent class&#039;s original method, you simply need to prepend the access to the original implementation with &#039;super.&#039; in order to use it.

Laterz,
J]]></description>
			<content:encoded><![CDATA[<p>I was going to ask if Flash had a super scope&#8230; I know CF does, but I also know that there are similarities and differences between the two platforms&#8230; and the two can be pretty stark.</p>
<p>But if you can use the super scope, you&#8217;re not overwriting your parent class&#8217;s original method, you simply need to prepend the access to the original implementation with &#8216;super.&#8217; in order to use it.</p>
<p>Laterz,<br />
J</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Chris Velevitch		</title>
		<link>https://jessewarden.com/2005/05/getter-setter-inheritance-gotcha.html/comment-page-1#comment-2585</link>

		<dc:creator><![CDATA[Chris Velevitch]]></dc:creator>
		<pubDate>Wed, 04 May 2005 06:54:35 +0000</pubDate>
		<guid isPermaLink="false">http://jessewarden.com/?p=795#comment-2585</guid>

					<description><![CDATA[oops that should read if p is less than 0.]]></description>
			<content:encoded><![CDATA[<p>oops that should read if p is less than 0.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Chris Velevitch		</title>
		<link>https://jessewarden.com/2005/05/getter-setter-inheritance-gotcha.html/comment-page-1#comment-2584</link>

		<dc:creator><![CDATA[Chris Velevitch]]></dc:creator>
		<pubDate>Wed, 04 May 2005 06:51:06 +0000</pubDate>
		<guid isPermaLink="false">http://jessewarden.com/?p=795#comment-2584</guid>

					<description><![CDATA[What you&#039;re saying is right, but I don&#039;t understand when you say it fails. The following case works, but is this an example of what you&#039;re trying to do?

class test2 {

	private var _x:Number;

	function test2() {
		_x=0;
	};
	
	function set x(p:Number):Void {
		_x = p;
		trace(&#039;_x=&#039;+p);
	}

}

class test1 extends test2 {
	
	function test1() {
		trace(&#039;test1.x=3&#039;);
		x=3; // traces x=3
		trace(&#039;test1.x=-3&#039;);
		x=-3; // traces x=0
	}
	
	function set x(p) {
		if (pWhat you&#039;re saying is right, but I don&#039;t understand when you say it fails. The following case works, but is this an example of what you&#039;re trying to do?

class test2 {

	private var _x:Number;

	function test2() {
		_x=0;
	};
	
	function set x(p:Number):Void {
		_x = p;
		trace(&#039;_x=&#039;+p);
	}

}

class test1 extends test2 {
	
	function test1() {
		trace(&#039;test1.x=3&#039;);
		x=3; // traces x=3
		trace(&#039;test1.x=-3&#039;);
		x=-3; // traces x=0
	}
	
	function set x(p) {
		if (p&lt;0)
			super.x = 0;
		else
			super.x = p;
	}
}]]></description>
			<content:encoded><![CDATA[<p>What you&#8217;re saying is right, but I don&#8217;t understand when you say it fails. The following case works, but is this an example of what you&#8217;re trying to do?</p>
<p>class test2 {</p>
<p>	private var _x:Number;</p>
<p>	function test2() {<br />
		_x=0;<br />
	};</p>
<p>	function set x(p:Number):Void {<br />
		_x = p;<br />
		trace(&#8216;_x=&#8217;+p);<br />
	}</p>
<p>}</p>
<p>class test1 extends test2 {</p>
<p>	function test1() {<br />
		trace(&#8216;test1.x=3&#8217;);<br />
		x=3; // traces x=3<br />
		trace(&#8216;test1.x=-3&#8217;);<br />
		x=-3; // traces x=0<br />
	}</p>
<p>	function set x(p) {<br />
		if (pWhat you&#8217;re saying is right, but I don&#8217;t understand when you say it fails. The following case works, but is this an example of what you&#8217;re trying to do?</p>
<p>class test2 {</p>
<p>	private var _x:Number;</p>
<p>	function test2() {<br />
		_x=0;<br />
	};</p>
<p>	function set x(p:Number):Void {<br />
		_x = p;<br />
		trace(&#8216;_x=&#8217;+p);<br />
	}</p>
<p>}</p>
<p>class test1 extends test2 {</p>
<p>	function test1() {<br />
		trace(&#8216;test1.x=3&#8217;);<br />
		x=3; // traces x=3<br />
		trace(&#8216;test1.x=-3&#8217;);<br />
		x=-3; // traces x=0<br />
	}</p>
<p>	function set x(p) {<br />
		if (p&lt;0)<br />
			super.x = 0;<br />
		else<br />
			super.x = p;<br />
	}<br />
}</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
