cocoa on-rails-5th

10
Ruby Cocoa on Rails 5th 2011-7-25

Upload: xiaochun-shen

Post on 19-Jan-2015

313 views

Category:

Education


6 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Cocoa on-rails-5th

Ruby

Cocoa on Rails5th

2011-7-25

Page 2: Cocoa on-rails-5th

这节课讲什么

Ruby 语法

Page 3: Cocoa on-rails-5th

Interactive Ruby

开始 -> 程序 ->Ruby 1.9.2->

Interactive Ruby

Page 4: Cocoa on-rails-5th

Hello World

Irb>puts “hello world”

=>”hello world”

=> nil

Page 5: Cocoa on-rails-5th

计算器

irb> 1 + 2

=> 3

Page 6: Cocoa on-rails-5th

数学公式

Irb>Math.sqrt(9)

=> 3.0

Page 7: Cocoa on-rails-5th

函数irb> def h

irb> puts "Hello World!"

irb> end

=> nil

=> h

=> h()

Page 8: Cocoa on-rails-5th

可接受参数的函数

irb> def h(name)

irb> puts "Hello #{name}!"

irb> end

irb> h(“Junli")

Page 9: Cocoa on-rails-5th

将代码放入文件

puts “hello world”

保存为 hello.rb

在命令行下,运行 ruby hello.rb

Page 10: Cocoa on-rails-5th

下一课程

待定