Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
第四講:控制流程、基本內建物件
Search
MROS
October 22, 2013
Programming
24
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
第四講:控制流程、基本內建物件
ases ruby上課講義(四)
MROS
October 22, 2013
Other Decks in Programming
See All in Programming
Domain-Driven Transformation
hschwentner
2
2.3k
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
800
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
28
33k
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
630
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
3
670
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
220
dotNET_vulnclicker_intro.pdf
deka_morita
0
140
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
3
440
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
1
440
golang-bob.pdf
iwatsukayura
0
130
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
Featured
See All Featured
Chasing Engaging Ingredients in Design
codingconduct
0
360
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
How to Ace a Technical Interview
jacobian
280
24k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Become a Pro
speakerdeck
PRO
31
6.3k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
360
Building Adaptive Systems
keathley
44
3.3k
GitHub's CSS Performance
jonrohan
1033
470k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
530
The Invisible Side of Design
smashingmag
301
52k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
Transcript
第四講 控制流程、物件
方法的進階使用 def test(a, b=3, c=4) print "#{a} #{b} #{c}" end
test(1, 5, 6) # 1 5 6 test(1, 5) # 1 5 4 test(1) # 1 3 4
範圍 (left..right) # 包含right (left...right) # 不包含right
字串 "string" 以雙引號刮起為最基本 總共大概有四、五種
子字串截取 a = “1234567” a[2] # “3” a[3] # “4”
a[-1] # “7” 由後往前數 a[2..4] # “345” a[3, 2] # “45”
一些方法 a = "to tHe end of the wORld." puts
a.capitalize puts a.upcase puts a.downcase puts a.capitalize! puts a.upcase! puts a.downcase!
a = "You are so beautiful...so beautiful." print a.include? "ar"
print a.gsub("beautiful", "ugly")
關於操作字串,還有非常非常多...... 請自行翻閱圖書或瀏覽網頁 或是透過 ri這個隨ruby一起安裝的文件查找程 式 其實就類似於unix的man一樣
陣列:創建 a = [] a = [1, 3, "dd"] a
= Array.new a = Array.new(3) a = Array.new(3, "hihi")
陣列:取值 a[i] a[i] = x
陣列:添加 a = [1, 2, 3] a.unshift(0) # a now
is [0, 1, 2, 3] a = [1, 2, 3] a.push(0) # a now is [1, 2, 3, 0] a = [1, 2, 3] a << 0 # a now is [1, 2, 3, 0] 以上僅有<<只能接一個參數
陣列:刪去 a = [1, 2, 3] a.pop # now a
is [1, 2] a = [1, 2, 3] a.shift #now a is [2, 3]
陣列裡的陣列 a = [[1, 2], 43, "pop", [8, [4]] a[0]
== [1, 2] a[0][0] == 1 a[3][1] == [4] a[3][1][0] == 4
練習成就完美 1.試製造由一到一百組成的的陣列 2.請將一個陣列的值由小排到大
迴圈:while while 判斷式 do_something end 可以break跳出
if之外的分支結構:unless unless x == 100 puts "不夠完美" else puts "夠了"
end
if, unless作為修飾語 print "天才" if IQ > 180
if之外的分支結構:when 下次再談