锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品无码专区在线,国产精品亚洲一区二区三区在线,久久精品亚洲综合专区http://www.tkk7.com/DustinTang/category/12833.htmlGDTzh-cnThu, 08 Mar 2007 04:40:24 GMTThu, 08 Mar 2007 04:40:24 GMT60Ruby Syntactic Sugarhttp://www.tkk7.com/DustinTang/archive/2006/07/06/56916.htmlDustin TangDustin TangThu, 06 Jul 2006 03:01:00 GMThttp://www.tkk7.com/DustinTang/archive/2006/07/06/56916.htmlhttp://www.tkk7.com/DustinTang/comments/56916.htmlhttp://www.tkk7.com/DustinTang/archive/2006/07/06/56916.html#Feedback0http://www.tkk7.com/DustinTang/comments/commentRss/56916.htmlhttp://www.tkk7.com/DustinTang/services/trackbacks/56916.html1. Hello World紼嬪簭
聽Ruby : puts "Hello World!"
聽java : public class HelloWorld {
聽聽聽public static void main(String[] args) {
聽聽聽聽System.out.println("Hello World!");
聽聽聽}
聽聽}
2. Every Thing is object
聽Ruby : -1979.abs
聽java : -1979.abs (Error! Sorry, -1979 is primary type, it should be Math.abs(-1979))
3. String
聽"abcd\nefg" ==> abcd鎹㈣efg
聽'abcd\nefg' ==> abcd\nefg
聽a=123, "abcd#{a}efg" ==> abcd123efg 'abcd#{a}efg' ==> abcd#{a}efg
4. Control Structure
聽while line=gets
聽聽puts line
聽end
聽puts line if line
5. Name convention
聽Local Variable : local_variable
聽Globle Variable : $globle_variable
聽instance : @instance
聽Class instance : @@class_instance
聽Constant and Class Name : ClassName
6. Hash
聽hash_map = {
聽聽1 =>"1",
聽聽2 =>"2"
聽}
聽hash_map[1] ==> "1"
7. Regular Expression
聽while line=gets
聽聽puts line if line=~/Hello/
聽end
8. Attribute
聽A.
聽聽def att=(att)
聽聽聽@att=att
聽聽end
聽聽def att
聽聽聽@att
聽聽end
聽聽class_object.att = 1;
聽B.
聽聽attr_reader :att
聽聽attr_writer :att
聽聽class_object.att = 1;
9. asignment
聽a1, a2 = a2, a1
10. numbers
聽num = 81
聽6.times do
聽聽puts "#{num.class}: #{num}"
聽聽num *= num
聽end
聽Result :
聽Fixnum: 81
聽Fixnum: 6561
聽Fixnum: 43046721
聽Bignum: 1853020188851841
聽Bignum: 3433683820292512484657849089281
聽Bignum: 11790184577738583171520872861412518665678211592275841109096961
聽You can get number as big as you can, it depends your memory.
OK, I think for us, these are pretty much like opening acts, y'know? I mean it's like the stand-up comedian you have to sit through before Pink Floyd comes out.
涓嬮潰鍑哄満鐨勬槸Ruby涓渶澶х殑緋栨灉:
Blocks
聽Blocks鍦╦ava涓栫晫涓渶瀵嗛泦鐨勫湴鍖哄彲鑳藉氨鏄疭pring Framework浜?鑰屽湪Ruby涓栫晫涓?Block闅忓鍙.
聽Block涓ょ褰㈠紡 :
聽鍗曡 {鍐呭鍦ㄨ繖閲寎
聽澶氳 do
聽聽鍐呭鍦ㄨ繖閲?br />聽聽榪樻湁榪欓噷
聽聽end
聽1.upto(6) {puts "Hello, World!"} 鎵撳嵃鍏Hello World
聽榪樺彲浠ュ甫鍙傛暟
聽1.upto(6) {|num| puts num} 鎵撳嵃1鍒?
鍘熺悊(鍋囦唬鐮?
聽class Number
聽聽def upto(up)
聽聽聽ini = @num
聽聽聽while ini <= up
聽聽聽聽yield(ini)
聽聽聽聽ini+=1
聽聽聽end
聽聽end
聽end
聽瑙i噴鍣ㄥ皢 {|num| puts num}浣滀負Call瀵硅薄浼犲叆, yield灝辨槸璋冪敤姝all瀵硅薄鐨勬柟娉?

Dustin Tang 2006-07-06 11:01 鍙戣〃璇勮
]]>
Best of Ruby Quizhttp://www.tkk7.com/DustinTang/archive/2006/07/05/56755.htmlDustin TangDustin TangWed, 05 Jul 2006 06:50:00 GMThttp://www.tkk7.com/DustinTang/archive/2006/07/05/56755.htmlhttp://www.tkk7.com/DustinTang/comments/56755.htmlhttp://www.tkk7.com/DustinTang/archive/2006/07/05/56755.html#Feedback1http://www.tkk7.com/DustinTang/comments/commentRss/56755.htmlhttp://www.tkk7.com/DustinTang/services/trackbacks/56755.html絎竴棰樸錛跡錛ゃ錛綍锝嶏絺锝咃綊锝?鐢墊閲岄潰鐨勬暟瀛楄榪囧惂, 鎶婄敤鎴瘋緭鍏ョ殑鏁板瓧杞崲涓篖CD鐨勬暟瀛? 闀?涓瓧, 楂?涓瓧)

鎴戠殑浠g爜(鍒濆鑰?澶у灝卞師璋呭垯涓?

class聽LCDNumber
聽聽@@number_code聽
=聽{
聽聽聽聽
"0"=>聽0b1110111,
聽聽聽聽
"1"=>聽0b0100100,
聽聽聽聽
"2"=>聽0b1011101,
聽聽聽聽
"3"=>聽0b1101101,
聽聽聽聽
"4"=>聽0b0101110,
聽聽聽聽
"5"=>聽0b1101011,
聽聽聽聽
"6"=>聽0b1111011,
聽聽聽聽
"7"=>聽0b0100101,
聽聽聽聽
"8"=>聽0b1111111,
聽聽聽聽
"9"=>聽0b1101111
聽聽}
聽聽def聽initialize(num)
聽聽聽聽@num聽
=聽num
聽聽end
聽聽def聽getZone(zone)
聽聽聽聽
if聽((@@number_code[@num]聽&聽(1<<聽zone))聽!=0)聽
聽聽聽聽聽聽st聽
=聽zone聽%3==0?"聽--聽"聽:聽(zone聽%3==1?"|聽"聽:聽"聽|")
聽聽聽聽
else
聽聽聽聽聽聽st聽
=聽zone聽%3==0?"聽聽聽聽"聽:聽"聽聽"
聽聽聽聽end
聽聽聽聽
return聽st
聽聽end
聽聽attr_reader聽:num
end
def聽get(zone,聽array)
聽聽s聽
=""
聽聽
for聽lcd_number聽in聽array
聽聽聽聽s聽
+=聽(zone聽%3==0?聽lcd_number.getZone(zone)聽:聽(zone聽%3==1?聽lcd_number.getZone(zone)聽+聽lcd_number.getZone(zone+1)聽:聽聽lcd_number.getZone(zone-1)聽+聽lcd_number.getZone(zone)))
聽聽end
聽聽
return聽s
end
require聽
"stringio"
while聽line=gets
聽聽a聽
=聽Array.new
聽聽si聽
=聽StringIO.new(line);
聽聽
while聽c=si.read(1)
聽聽聽聽a.push(LCDNumber.
new(c))聽if聽(c聽>='0'&&聽c聽<='9')
聽聽end
聽聽
0.upto(6)聽{|line|聽puts聽get(line,聽a)}
end


Dustin Tang 2006-07-05 14:50 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 国产免费久久精品丫丫| 亚洲色精品VR一区区三区| 一级毛片免费播放男男| 免费a级毛片大学生免费观看| 亚洲欧美成人一区二区三区| 美女黄网站人色视频免费国产 | 91情国产l精品国产亚洲区| a毛片在线免费观看| 国产精品久久久亚洲| 久久精品一区二区免费看| 亚洲视频免费观看| 久久99九九国产免费看小说| 亚洲熟妇无码八V在线播放| 国产jizzjizz视频免费看| 一本久久A久久免费精品不卡| 最新国产AV无码专区亚洲| 免费在线看黄的网站| 亚洲国产精品一区二区久| 毛片免费观看网站| 成年免费a级毛片| 无码专区—VA亚洲V天堂| 波多野结衣在线免费视频| 亚洲av乱码一区二区三区按摩| 亚洲精品无码专区2| 久久久久成人精品免费播放动漫| 亚洲国产成人久久三区| 国产一区二区三区在线免费 | h片在线观看免费| 亚洲av福利无码无一区二区| 1000部拍拍拍18勿入免费视频下载| 亚洲日韩一区精品射精| 超清首页国产亚洲丝袜| 久久www免费人成看片| 久久精品亚洲日本波多野结衣| 久久乐国产精品亚洲综合| 性短视频在线观看免费不卡流畅| WWW国产亚洲精品久久麻豆| 亚洲AV一宅男色影视| 国产小视频在线免费| 国产成人精品无码免费看| 亚洲日韩国产欧美一区二区三区 |