<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>hivandu (Hivan Du)</title>
    <link>https://ruby-china.org/hivandu</link>
    <description>Hivan</description>
    <language>en-us</language>
    <item>
      <title>一段代码有错误提示，但是找不出错误原因，求解</title>
      <description>&lt;pre class="highlight plaintext"&gt;&lt;code&gt;text =%q{
  Ruby is a great programming language.It is object oriented and has many groovy features.Some people don't like it, but that's not our problem! It's easy to learn. It's great. To learn more about Ruby,visit the official Ruby Web site today.
}

sentences =text.gsub(/\s+/, '').strip.split(/\.|\?|\!/)
sentences_sorted =sentences.sort_by{|sentence|sentence.length}
one_third =sentences_sorted.length /3
ideal_sentences =sentences_sorted.slice(one_third,one_third +1)
ideal_sentences =ideal_sentences.select {|sentence|sentence =-/is|are/}
puts ideal_sentences.join(".")
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;错误提示：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;summarize.rb:9: syntax error, unexpected '}'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;就是找不出来！因为初学者，看书上是这样写的，不过书本的版本为 1.8，所以不知道是不是版本问题！&lt;/p&gt;

&lt;p&gt;还望大大指教！谢谢...&lt;/p&gt;</description>
      <author>hivandu</author>
      <pubDate>Mon, 27 Aug 2012 17:59:12 +0800</pubDate>
      <link>https://ruby-china.org/topics/5187</link>
      <guid>https://ruby-china.org/topics/5187</guid>
    </item>
  </channel>
</rss>
