<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    ruby學(xué)習(xí)筆記(1)

    發(fā)現(xiàn)了這個(gè)學(xué)習(xí)ruby的好地方,每天就盡量抽點(diǎn)時(shí)間學(xué)習(xí)一下吧。
    http://www.rubylearning.com/forum/

    今天學(xué)習(xí)第一課,比較簡(jiǎn)單.

    1.1 Introduction
          簡(jiǎn)介ruby
        
    1.2
    Installation
          1)
    Downloading Ruby and an Editor
                下載地址: Ruby Installer for Windows
                 安裝包中包括一個(gè)ruby的編輯器SciTE.            

           2)Ruby Programming Environment:            
                 假設(shè)我們裝在C:/ruby目錄下,系統(tǒng)將創(chuàng)建一些新的文件夾。
              
                c:/ruby/bin:ruby子帶的命令以及可執(zhí)行文件
                c:
    /ruby/lib/ruby/1.8:ruby的一些標(biāo)準(zhǔn)庫(kù)
                c:
    /ruby/lib/ruby/1.8/i386-mswin32:與平臺(tái)相關(guān)聯(lián)的庫(kù)
                c:
    /ruby/lib/ruby/site_ruby: 存放工具庫(kù)或第三方庫(kù)
                c:
    /ruby/lib/ruby/gems: Ruby-Gems 包目錄.
                c:
    /ruby/src:ruby代碼目錄.
                c:
    /ruby/samples/RubySrc-1.8.6/sample: ruby例子代碼目錄.      

    1.3 First Ruby program
                1) 可以使用ruby自帶的
    SciTE.作為編輯器(程序->ruby->SciTE). 對(duì)于SciTE,使用F8打開輸出,F(xiàn)5運(yùn)行ruby程序
                2) ruby的文件一般以.rb后綴
                3) 經(jīng)典的hellowor!(在SciTE中新建文件hello.rb,然后輸入)
                        puts 'Hello ' + "world " + 'ruby!'
                4)  總結(jié):
                       a. 不需要main方法或者函數(shù)
                       b. 字符串可以用‘’ 、“”
                       c. ruby是腳本語言,直接運(yùn)行,不需要編譯
                       d. ruby的命名規(guī)范建議文件名為小寫,如Foo class命名foo.rb

    1.4 Features of Ruby
               1) 大小寫敏感
               2) 單行注釋可以用#,多行注釋可以用=begin開始,=end結(jié)束
               3) 一行中的多行代碼必須用;分割
               4)使用\轉(zhuǎn)義 或者  連接多行

    1.5
    Numbers in Ruby
               在ruby中,帶.的
    數(shù)稱為浮點(diǎn)數(shù),不帶.的數(shù)稱為整數(shù)
                1) 整數(shù)和整數(shù)的操作結(jié)果為整數(shù)
                2) ruby使用
    Fixnum(默認(rèn))和Bignum處理超大數(shù)
                3) 繼承結(jié)構(gòu):
                                             Object
                                                  |
                                             Numric
                                          |              |
                                     Integer      Float
                                          |
                              Bignum  Fixnum

    1.6 String fundamentals
              在ruby中,ruby作為bytes的序列存儲(chǔ),不像java的String不可修改
             1) 字符串可以使用“ ”或者' ',但' '更有效
             2) 使用\轉(zhuǎn)義
             3) 可以使用` ` 執(zhí)行Console 命令, 如 puts `dir`等

    1.7
    Variables and Assignment
             在ruby中,當(dāng)解釋器判斷到賦值符號(hào)=,就認(rèn)為存在一個(gè)變量.
              1) 局部變量由_或者小寫字母開頭,由字母、數(shù)字、下劃線組成
              2) << 可以向一個(gè)字符串中添加字符串,如
    a = 'hello '; a<<'world.
     

    1.8 總結(jié):(原網(wǎng)站上的總結(jié),很容易理解)
       * We are discussing about Ruby 1.8.6 on a Windows platform.
        
    * Ruby is an interpreted language
        
    * In Ruby, there's always more than one way to solve a given problem.
        * The code examples would be run in the SciTE editor and ensure that you have done the relevant settings as mentioned on the page "First Ruby program".
        
    * All Ruby source files have the .rb file extension.
        
    * In Ruby, program execution proceeds in general from top to bottom.
        
    * Features: Free format, Case sensitive, Two type of comments, Statement delimiters are not required, Around 38 Keywords
        
    * You may be used to thinking that a false value may be represented as a zero, a null string, a null character, or various other things. But in Ruby, all of these are true; in fact, everything is true except the reserved words false and nil.
        
    * We shall be referring to the documentation here - http://www.ruby-doc.org/core/
        * puts (s in puts stands for string; puts really means put string) simply writes onto the screen whatever comes after it, but then it also automatically goes to the next line.
        
    * Parentheses are usually optional with a method call. These calls are all valid:
          foobar
          foobar()
          foobar(a, b, c)
          foobar a, b, c
        
    * In Ruby, numbers without decimal points are called integers, and numbers with decimal points are usually called floating-point numbers or, more simply, floats (you must place at least one digit before the decimal point).
        
    * Some very common Ruby operators:+ addition; - subtraction; * multiplication; / division
        
    * The increment and decrement operators (++ and --) are not available in Ruby, neither in "pre" nor "post" forms.
        
    * Anything inside brackets is calculated first (or, more technically, given higher precedence).
        
    * Observe how the modulus operator (%) works in Ruby.
        
    * When you do arithmetic with integers, you'll get integer answers.
        * String literals are sequences of characters between single or double quotation marks.
        
    * In Ruby, strings are mutable. They can expand as needed, without using much time and memory.
        
    * String concatenation is joining of two strings, using the + operator.
        
    * Escape sequence is the \ character. Examples: \", \\, \n
        * '' is an empty string.
        
    * If you get a compilation error like -
          #
    <TypeError: can't convert Fixnum into String>
          it means that you can't really add a number to a string, or multiply a string by another string.
        * Constants begin with capital letters. Example PI, Length
        
    * A variable springs into existence as soon as the interpreter sees an assignment to that variable. It is a good practice to assign nil to a variable initially.
        
    * x, y = y, x will interchange the values of x and y.
        
    * Local variables must start with either a lowercase letter or the underscore character (_), and they must consist entirely of letters, numbers, and underscores.Examples: india, _usa, some_var
        
    * .to_i, .to_f, .to_s are used to convert to an integer, float, string respectively.
        
    * The operator << is used to append to a string

    posted on 2007-09-28 18:26 想飛就飛 閱讀(4841) 評(píng)論(4)  編輯  收藏 所屬分類: ROR

    評(píng)論

    # re: ruby學(xué)習(xí)筆記(1) 2007-09-29 15:56 mudong

    哥們 繼續(xù)寫   回復(fù)  更多評(píng)論   

    # re: ruby學(xué)習(xí)筆記(1) 2007-10-10 21:18 雪兒

    寫的很好 繼續(xù)啊!! 期待中  回復(fù)  更多評(píng)論   

    # re: ruby學(xué)習(xí)筆記(1)[未登錄] 2008-01-29 12:15 呵呵

    很不錯(cuò)  回復(fù)  更多評(píng)論   

    # re: ruby學(xué)習(xí)筆記(1) 2009-04-07 13:48 coolfish

    多謝分享,贊一個(gè)。
    繼續(xù)寫。
      回復(fù)  更多評(píng)論   

    公告


    導(dǎo)航

    <2007年9月>
    2627282930311
    2345678
    9101112131415
    16171819202122
    23242526272829
    30123456

    統(tǒng)計(jì)

    常用鏈接

    留言簿(13)

    我參與的團(tuán)隊(duì)

    隨筆分類(69)

    隨筆檔案(68)

    最新隨筆

    搜索

    積分與排名

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: 91精品国产亚洲爽啪在线观看| 亚洲中久无码不卡永久在线观看| 4444亚洲国产成人精品| a国产成人免费视频| 中文字幕精品亚洲无线码一区| 一级黄色免费网站| 亚洲午夜福利精品久久| 亚洲高清免费视频| 情人伊人久久综合亚洲| 午夜免费啪视频在线观看 | 亚洲日韩一中文字暮| 欧美a级在线现免费观看| jlzzjlzz亚洲jzjzjz| 成年美女黄网站色大免费视频| 国产亚洲福利在线视频| 国产一级淫片免费播放| 有码人妻在线免费看片| 日韩va亚洲va欧洲va国产| 91成人在线免费视频| 亚洲人成网站色在线观看| 国产成人精品免费直播| 老司机午夜免费视频| 亚洲人成网77777色在线播放| 国产精成人品日日拍夜夜免费 | 免费看国产一级片| 亚洲制服丝袜在线播放| 日韩电影免费在线| 免费看一区二区三区四区| 久久久受www免费人成| 亚洲国产av一区二区三区丶| 亚洲三级电影网址| 亚洲免费人成视频观看| 亚洲综合小说另类图片动图| 亚洲精品色在线网站| 久久国产精品免费一区| 成年在线观看网站免费| 国产精彩免费视频| 免费在线观看中文字幕| 久久国产精品亚洲一区二区| 亚洲免费视频播放| 国产免费A∨在线播放|