<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://trans.onionmixer.net/wiki/index.php?action=history&amp;feed=atom&amp;title=SqueakByExample%3A9.6</id>
	<title>SqueakByExample:9.6 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://trans.onionmixer.net/wiki/index.php?action=history&amp;feed=atom&amp;title=SqueakByExample%3A9.6"/>
	<link rel="alternate" type="text/html" href="https://trans.onionmixer.net/wiki/index.php?title=SqueakByExample:9.6&amp;action=history"/>
	<updated>2026-05-02T01:31:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.3</generator>
	<entry>
		<id>https://trans.onionmixer.net/wiki/index.php?title=SqueakByExample:9.6&amp;diff=2112&amp;oldid=prev</id>
		<title>Onionmixer: 번역수정</title>
		<link rel="alternate" type="text/html" href="https://trans.onionmixer.net/wiki/index.php?title=SqueakByExample:9.6&amp;diff=2112&amp;oldid=prev"/>
		<updated>2013-09-13T16:38:12Z</updated>

		<summary type="html">&lt;p&gt;번역수정&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==컬렉션 사용에 대한 몇 가지 힌트==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;add: 메서드를 사용할 때 발생되는 일반적인 실수:&amp;#039;&amp;#039;&amp;#039; 다음의 에러는 가장 많이 발생되는 스몰토크 코딩에서의 실수 중 하나 입니다.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
collection := OrderedCollection new add: 1; add: 2.&lt;br /&gt;
collection    ⇒    2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
여기서 보게되는 변수 collection 은 새롭게 만들어진 컬렉션이 아니라, 마지막에 추가된 숫자를 보관합니다. 왜냐하면 메서드 add: 는 추가된 요소를 반환하되, 수신자는 반환하지 않기 때문입니다.&lt;br /&gt;
&lt;br /&gt;
다음 코드에서 예상대로의 결과를 얻을 수 있습니다:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
collection := OrderedCollection new.&lt;br /&gt;
collection add: 1; add: 2.&lt;br /&gt;
collection    ⇒    an OrderedCollection(1 2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
그외에 yourself 메시지를 사용할 수 있는데, 이 메시지는 cascade 된 메시지의 수신자를 반환합니다.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
collection := OrderedCollection new add: 1; add: 2; yourself     ⇒    an OrderedCollection(1 2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;반복을 수행하고 있는 콜렉션으로부터 요소를 삭제.&amp;#039;&amp;#039;&amp;#039; 자주 일어날 수 있는 또 다른 실수는, 현재 반복작업을 수행하는 컬렉션으로부터 요소를 제거하는 것입니다. remove: 를 이용하는 경우에 말이죠.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
range := (2 to: 20) asOrderedCollection.&lt;br /&gt;
range do: [:aNumber | aNumber isPrime ifFalse: [ range remove: aNumber ] ].&lt;br /&gt;
range    ⇒    an OrderedCollection(2 3 5 7 9 11 13 15 17 19)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
9 와 15 가 걸러져야 했기 때문에, 이 결과는 잘못된 결과입니다.&lt;br /&gt;
&lt;br /&gt;
해결 방법은, 검사를 하기 전에 컬렉션을 복사해 두는 것입니다. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
range := (2 to: 20) asOrderedCollection.&lt;br /&gt;
range copy do: [:aNumber | aNumber isPrime ifFalse: [ range remove: aNumber ] ].&lt;br /&gt;
range    ⇒    an OrderedCollection(2 3 5 7 11 13 17 19)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;= 와 hash 는 한번에 양쪽 모두 재정의 되어야 한다.&amp;#039;&amp;#039;&amp;#039; 에러중 발견하기 어려운 경우는, 사용자가 = 을 재정의하면서 hash 는 재정의하지 않는 경우입니다. 이런경우 Set 에 분명히 넣은 요소가 어느새 없어진다는 현상등이 나타납니다. Kent Beck 이 제안한 해결책은 xor: 을 이용해서 bash를 재정의 하는 것입니다. 예를 들어, 만약 제목과 저자가 같은경우, 두 개의 책을 동일한 것으로 판단하고 싶을때, 다음과 같이 = 를 재정의할 뿐만 아니라 hash도 재정의 해야 할 것입니다.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
메서드 9.1 = 과 hash 재정의 하기&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Book»= aBook&lt;br /&gt;
  self class = aBook class ifFalse: [↑ false].&lt;br /&gt;
  ↑ title = aBook title and: [ authors = aBook authors]&lt;br /&gt;
&lt;br /&gt;
Book»hash&lt;br /&gt;
  ↑ title hash xor: authors hash&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
만약 Set 의 요소 또는 Dictionary 에 대한 key 를, 그 자체의 hash 값의 변경이 가능한 객체처럼-수정가능한 객체를 사용하는 경우에는, 또 다른 끔찍한 문제가 발생합니다. 당신이 디버깅을 정말로 좋아하는게 아니라면, 이런 경우에는 수정가능한 객체를 사용하지 말아주세요!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:SqueakByExample]]&lt;/div&gt;</summary>
		<author><name>Onionmixer</name></author>
	</entry>
	<entry>
		<id>https://trans.onionmixer.net/wiki/index.php?title=SqueakByExample:9.6&amp;diff=2109&amp;oldid=prev</id>
		<title>Onionmixer at 05:10, 30 August 2012</title>
		<link rel="alternate" type="text/html" href="https://trans.onionmixer.net/wiki/index.php?title=SqueakByExample:9.6&amp;diff=2109&amp;oldid=prev"/>
		<updated>2012-08-30T05:10:35Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 05:10, 30 August 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l8&quot;&gt;Line 8:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;여기에 나온 변수 컬렉션(collection)은 새롭게 만들어진 컬렉션(collection)을 보유하지 않고 오히려 추가된 마지막 숫자를 보유합니다. 그 이유는 &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;메소드 &lt;/del&gt;add:가 추가된 구성요소를 리턴하고 수신자(the receiver)를 리턴하지 않기 때문입니다.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;여기에 나온 변수 컬렉션(collection)은 새롭게 만들어진 컬렉션(collection)을 보유하지 않고 오히려 추가된 마지막 숫자를 보유합니다. 그 이유는 &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;메서드 &lt;/ins&gt;add:가 추가된 구성요소를 리턴하고 수신자(the receiver)를 리턴하지 않기 때문입니다.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;다음 코드는 기대한 결과를 도출합니다:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;다음 코드는 기대한 결과를 도출합니다:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l45&quot;&gt;Line 45:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 45:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;메소드 &lt;/del&gt;9.1 =과 hash를 재정의 하기&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;메서드 &lt;/ins&gt;9.1 =과 hash를 재정의 하기&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Book»= aBook&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Book»= aBook&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Onionmixer</name></author>
	</entry>
	<entry>
		<id>https://trans.onionmixer.net/wiki/index.php?title=SqueakByExample:9.6&amp;diff=2108&amp;oldid=prev</id>
		<title>Onionmixer: SBE 컬렉션사용을위한몇가지힌트 페이지 추가</title>
		<link rel="alternate" type="text/html" href="https://trans.onionmixer.net/wiki/index.php?title=SqueakByExample:9.6&amp;diff=2108&amp;oldid=prev"/>
		<updated>2012-08-17T04:02:56Z</updated>

		<summary type="html">&lt;p&gt;SBE 컬렉션사용을위한몇가지힌트 페이지 추가&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==컬렉션 사용을 위한 몇 가지 힌트==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;add:를 사용할 때 저지르는 일반적인 실수:&amp;#039;&amp;#039;&amp;#039; 다음 에러는 가장 빈번한 스몰토크 실수들 중의 하나 입니다.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
collection := OrderedCollection new add: 1; add: 2.&lt;br /&gt;
collection    ⇒    2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
여기에 나온 변수 컬렉션(collection)은 새롭게 만들어진 컬렉션(collection)을 보유하지 않고 오히려 추가된 마지막 숫자를 보유합니다. 그 이유는 메소드 add:가 추가된 구성요소를 리턴하고 수신자(the receiver)를 리턴하지 않기 때문입니다.&lt;br /&gt;
&lt;br /&gt;
다음 코드는 기대한 결과를 도출합니다:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
collection := OrderedCollection new.&lt;br /&gt;
collection add: 1; add: 2.&lt;br /&gt;
collection    ⇒    an OrderedCollection(1 2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
여러분은 또한 메시지들의 캐스케이드(cascade)의 수신자를 리턴하기 위해 메시지 yourself를 사용할 수 있습니다.  &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
collection := OrderedCollection new add: 1; add: 2; yourself     ⇒    an OrderedCollection(1 2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;여러분이 반복적용(iterating)을 수행하는 컬렉션에 있는 구성요소를 제거합니다.&amp;#039;&amp;#039;&amp;#039; 여러분이 할 수 있는 다른 실수는 여러분이 현재 반복적용을 수행하는 위치인 컬렉션에 있는 구성요소를 제거하는 것입니다. remove:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
range := (2 to: 20) asOrderedCollection.&lt;br /&gt;
range do: [:aNumber | aNumber isPrime ifFalse: [ range remove: aNumber ] ].&lt;br /&gt;
range    ⇒    an OrderedCollection(2 3 5 7 9 11 13 15 17 19)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
9와 15가 필터링 되었어야만 했었기 때문에, 결과는 명백하게 정확한 것은 아닙니다.&lt;br /&gt;
&lt;br /&gt;
솔루션은 철저한 검사를 하기 전에 컬렉션(collection)을 복사하는 것입니다. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
range := (2 to: 20) asOrderedCollection.&lt;br /&gt;
range copy do: [:aNumber | aNumber isPrime ifFalse: [ range remove: aNumber ] ].&lt;br /&gt;
range    ⇒    an OrderedCollection(2 3 5 7 11 13 17 19)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;= 와 hash를 재정의 합니다.&amp;#039;&amp;#039;&amp;#039; 알아내기가 어려운 에러는 여러분이 =를 재정의 할 때이며, hash를 재정의 할 때가 아닙니다. 이 에러의 증상들은 세트(sets)에 집어넣을 구성요소들을 손실하게 되거나 다른 이상한 동작이 발생하는 것입니다. Kent Beck에 의해 제안된 솔루션은 hash를 재정의 하기 위해 xor:을 사용하는 것입니다. 만약 우리가 제목과 저자가 동일할 경우, 두 개의 책이 동일한 것으로 간주될 2 권의 책을 원한다고 가정해 본다면, 우리는 다음과 같이 =를 재정의할 뿐만 아니라 hash도 재정의 해야 할 것입니다.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
메소드 9.1 =과 hash를 재정의 하기&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Book»= aBook&lt;br /&gt;
  self class = aBook class ifFalse: [↑ false].&lt;br /&gt;
  ↑ title = aBook title and: [ authors = aBook authors]&lt;br /&gt;
&lt;br /&gt;
Book»hash&lt;br /&gt;
  ↑ title hash xor: authors hash&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
만약 여러분이 예를 들어 Set의 구성요소 또는 Dictionary에 대한 Key로서 그 자체의 hash 값을 변경할 수 있는 오브젝트와 같이, 수정 가능한 오브젝트(mutable object)를 사용하신다면, 또 다른 끔찍한 문제가 발생합니다. 여러분이 디버깅을 사랑하지 않는다면, 수정 가능한 오브젝트를 사용하지 말아 주세요!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:SqueakByExample]]&lt;/div&gt;</summary>
		<author><name>Onionmixer</name></author>
	</entry>
</feed>