ivaneeo's blog

          自由的力量,自由的生活。

            BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
            669 Posts :: 0 Stories :: 64 Comments :: 0 Trackbacks
            def say_goodnight(name)
          result = "Good night, #{name}" ##把變量name的值替換進字符串,ruby使用#{var}.
          return result
          end
          puts say_goodnight('Pa')
          ##########################################################

          def say_goodnight(name)
          result = "Good night, #{name.capitalize}" ##s.capitalize 第一個子母變?yōu)榇髮?br /> ##s.capitalize!
          ##Returns a copy of s with the first character converted to uppercase and the remainder to lowercase.
          ##"fooBar".capitalize # => "Foobar"
          return result
          end
          puts say_goodnight('uncle')
          ##########################################################

          $greeting = "Hello" # $greeting is a global variable
          @name = "Prudence" # @name is an instance variable
          puts "#$greeting, #@name"

          ##########################################################
          def say_goodnight(name) ##不用使用return語句也可以返回
          "Good night, #{name}"
          end
          puts say_goodnight('Ma')

          posted on 2006-09-12 15:05 ivaneeo 閱讀(288) 評論(0)  編輯  收藏 所屬分類: ruby-寶石也鋒芒
          主站蜘蛛池模板: 庆城县| 巴塘县| 雷波县| 台安县| 芦溪县| 衡阳县| 浮山县| 稻城县| 民勤县| 宕昌县| 健康| 怀远县| 防城港市| 平远县| 仲巴县| 股票| 乌拉特后旗| 博乐市| 黄浦区| 龙南县| 晋江市| 铁力市| 定襄县| 清水河县| 东乡| 永善县| 临武县| 紫金县| 社会| 保靖县| 永康市| 阜平县| 扶绥县| 镇原县| 积石山| 建瓯市| 萍乡市| 黎川县| 枣庄市| 建始县| 昂仁县|