<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://eiffelroom.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>eiffelroom - io - Comments</title>
 <link>http://eiffelroom.com/tag/io</link>
 <description>Comments for &quot;io&quot;</description>
 <language>en</language>
<item>
 <title>Typo?</title>
 <link>http://eiffelroom.com/blog/great_jasmini/eiffel_help_for_beginner_please#comment-210</link>
 <description>&lt;p&gt;Hello Jasmine,&lt;/p&gt;

&lt;p&gt;Firstly, it would be easier to read your code if you included it within eiffel XML tags (see MediaWiki syntax when posting).&lt;/p&gt;

&lt;p&gt;I can see a few problems with your code.&lt;/p&gt;

&lt;p&gt;Firstly, it should be &lt;code class=&quot;geshifilter eiffel&quot;&gt;io.&lt;span style=&quot;color: #000060;&quot;&gt;last_string&lt;/span&gt;&lt;/code&gt; (you omitted the io.).  Secondly, I think you need to call &lt;code class=&quot;geshifilter eiffel&quot;&gt;io.&lt;span style=&quot;color: #000060;&quot;&gt;last_string&lt;/span&gt;.&lt;span style=&quot;color: #000060;&quot;&gt;twin&lt;/span&gt;&lt;/code&gt;, which will copy the last string. The problem is that &lt;code class=&quot;geshifilter eiffel&quot;&gt;io.&lt;span style=&quot;color: #000060;&quot;&gt;last_string&lt;/span&gt;&lt;/code&gt; is re-used, so all the entries in your array point to the same object.&lt;/p&gt;

&lt;p&gt;Thirdly, since you know the size of the array, it would be better to size it correctly, and use put, not force.&lt;/p&gt;

&lt;p&gt;Also, avoid loops when you can (not always possible). Agents are better.&lt;/p&gt;

&lt;p&gt;So something like this:&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;geshifilter eiffel&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;feature&lt;/span&gt; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Test&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
test &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;is&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Test reading multiple words from standard input&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;local&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;my_array: &lt;a href=&quot;http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fdocs.eiffel.com%2Feiffelstudio%2Flibraries+ARRAY&amp;btnI=I%27m+Feeling+Lucky&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;ARRAY&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fdocs.eiffel.com%2Feiffelstudio%2Flibraries+STRING&amp;btnI=I%27m+Feeling+Lucky&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;STRING&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;i: &lt;a href=&quot;http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fdocs.eiffel.com%2Feiffelstudio%2Flibraries+INTEGER&amp;btnI=I%27m+Feeling+Lucky&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;INTEGER&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;do&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;create&lt;/span&gt; my_array.&lt;span style=&quot;color: #000060;&quot;&gt;make&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;from&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; i := &lt;span style=&quot;color: #FF0000;&quot;&gt;1&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;until&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; i &amp;gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;loop&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; io.&lt;span style=&quot;color: #000060;&quot;&gt;read_word&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; my_array.&lt;span style=&quot;color: #000060;&quot;&gt;put&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;io.&lt;span style=&quot;color: #000060;&quot;&gt;last_string&lt;/span&gt;.&lt;span style=&quot;color: #000060;&quot;&gt;twin&lt;/span&gt;, i&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; i := i + &lt;span style=&quot;color: #FF0000;&quot;&gt;1&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;my_array.&lt;span style=&quot;color: #000060;&quot;&gt;do_all&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;agent&lt;/span&gt; print_line&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
print_line &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;a_string: &lt;a href=&quot;http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fdocs.eiffel.com%2Feiffelstudio%2Flibraries+STRING&amp;btnI=I%27m+Feeling+Lucky&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;STRING&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;is&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Print `a_string&#039; on standard output followed by a new line.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;require&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;a_string_not_void: a_string /= &lt;span style=&quot;color: #800080;&quot;&gt;Void&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;do&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;print &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;a_string + &lt;span style=&quot;color: #0080A0;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #005070; font-weight: bold;&quot;&gt;%N&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;/div&gt; Colin Adams&lt;/p&gt;

</description>
 <pubDate>Thu, 19 Apr 2007 22:49:43 -0700</pubDate>
 <dc:creator>colin-adams</dc:creator>
 <guid isPermaLink="false">comment 210 at http://eiffelroom.com</guid>
</item>
</channel>
</rss>
