使用ruby語(yǔ)言編程的感覺(jué)是,一次又一次的驚嘆,非常神奇有人竟然把我之前用c、c++等語(yǔ)言編程時(shí)所遭遇的痛苦一次又一次地?fù)崞健?/p>
企業(yè)建站必須是能夠以充分展現(xiàn)企業(yè)形象為主要目的,是企業(yè)文化與產(chǎn)品對(duì)外擴(kuò)展宣傳的重要窗口,一個(gè)合格的網(wǎng)站不僅僅能為公司帶來(lái)巨大的互聯(lián)網(wǎng)上的收集和信息發(fā)布平臺(tái),創(chuàng)新互聯(lián)面向各種領(lǐng)域:純水機(jī)等成都網(wǎng)站設(shè)計(jì)、全網(wǎng)整合營(yíng)銷推廣解決方案、網(wǎng)站設(shè)計(jì)等建站排名服務(wù)。
下面這段代碼是我照教材敲出來(lái)的(summarize.rb),用于從一段文本中選擇包含感興趣的句子。
- 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(".")
#ruby summarize.rb運(yùn)行之后,彈出一個(gè)bug:summarize.rb:12: syntax error, unexpected '}'。
但是檢查數(shù)遍,也沒(méi)看出個(gè)所以然。倒是將one_third直接賦常量后,就OK了。繼續(xù)找找原因吧。