forked from lrthw/lrthw.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
668 lines (490 loc) · 20.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Learn Ruby The Hard Way</title>
<meta name="author" content="xdite">
<meta name="description" content=" 《 笨方法學 Ruby 》(Learn Ruby The Hard Way)是 Zed Shaw 編寫的一本Ruby 入門書籍。適合對電腦了解不多,沒有學過寫程式,但對寫程式感興趣的朋友學習使用。這本書以習題的方式引導讀者一步一步學習寫程式,從簡單的打印一直講到完整專案的實...">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="http://lrthw.github.com/">
<link href="/favicon.png" rel="icon">
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="/javascripts/modernizr-2.0.js"></script>
<script src="/javascripts/ender.js"></script>
<script src="/javascripts/octopress.js" type="text/javascript"></script>
<link href="/atom.xml" rel="alternate" title="Learn Ruby The Hard Way" type="application/atom+xml">
<!--Fonts from Google"s Web font directory at http://google.com/webfonts -->
<link href="http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
</head>
<body >
<header role="banner"><hgroup>
<h1><a href="/">Learn Ruby The Hard Way</a></h1>
<h2>笨方法學 Ruby</h2>
</hgroup>
</header>
<nav role="navigation"><ul class="subscription" data-subscription="rss">
<li><a href="/atom.xml" rel="subscribe-rss" title="subscribe via RSS">RSS</a></li>
</ul>
<form action="http://google.com/search" method="get">
<fieldset role="search">
<input type="hidden" name="q" value="site:lrthw.github.com" />
<input class="search" type="text" name="q" results="0" placeholder="Search"/>
</fieldset>
</form>
<ul class="main-navigation">
<li><a href="/">Blog</a></li>
<li><a href="/blog/archives">Archives</a></li>
</ul>
</nav>
<div id="main">
<div id="content">
<div class="blog-index">
<article>
<p>《 笨方法學 Ruby 》(Learn Ruby The Hard Way)是 Zed Shaw 編寫的一本Ruby 入門書籍。適合對電腦了解不多,沒有學過寫程式,但對寫程式感興趣的朋友學習使用。這本書以習題的方式引導讀者一步一步學習寫程式,從簡單的打印一直講到完整專案的實現。也許讀完這本書並不意味著你已經學會了寫程式,但至少你會對程式語言以及開發程式這個行業有一個初步的了解。</p>
<p>筆者認為本書區別於其它入門書籍的特點如下:</p>
<ul>
<li><strong>注重實踐</strong>。本書提供了足夠的練習代碼,如果你完成了所有的練習(包括加分習題),那你已經寫了上萬行的代碼。要知道很多職業程式設計師一年也就寫幾萬行程式碼而已。</li>
<li><strong>注重能力培養</strong>。除了原序言提到的「讀和寫」、「注重細節」、以及「發現不同」這樣的基本能力以外,本書還培養了讀者自己鑽研問題和尋求答案的能力。</li>
<li><strong>注重好習慣的養成</strong>。本書詳細地講解了怎樣寫出好的代碼、好的註釋、好的項目。這會讓你在後續的學習中少走很多彎路。</li>
</ul>
<p>本書結構非常簡單,其實就是52 個習題而已。其中26 個覆蓋了輸入輸出、變量、以及函式三個課題,另外 26 個覆蓋了一些比較進階的話題,如條件判斷、迴圈、類和物件、程式碼測試、以及專案的實現等。每一章節的格式基本都是一樣的,以程式碼練習題開始,讀者照著說明編寫程式碼(不允許複製貼上),運行並檢查結果,然後再做一下加分習題就可以了。當然如果你覺得加分習題對你來說有點難,你也可以暫時跳過,以後再完成也沒關係。</p>
<p>另外閱讀本書還需要你有一定的英文能力。其實學習寫程式不懂英語是很吃虧的,畢竟編程語言都是基於英語,而程式社群的主要交流方式也是英語。不會英語的人在程式界可能就只好當二等公民了。本書的翻譯盡量保留了所有的英文專業詞彙(可能會有中文說明),而且遵照 Zed 的建議,程式碼及答案部分沒有翻譯成中文,讀者看到不懂的地方,請自己查字典解決。</p>
<p>如果你對自己的英文能力比較有信心,譯者強烈推薦你直接去下載閱讀英文原版。這本書代碼較多,文字內容較少,因此英文原版的閱讀理解也比較容易。</p>
<p>LRTHW的風格和別的書差異很大。它沒有像一般的入門書籍一樣通過討好讀者以激發讀者興趣,而是直截了當地告訴你你需要做什麼,需要注意什麼。這種風格可能會讓人覺得枯燥乏味,讀者姑且把這也當做 Hard Way 的一部分吧。</p>
<p> <a href="http://readthedocs.org/docs/learn-python-the-hard-way-zh_cn-translation/en/latest/index.html">LPTHW 簡體中文版</a>的翻譯者是 <a href="mailto:wangdingwei82@gmail.com">wangdingwei82@gmail.com</a>,而他的 blog 是 <a href="http://ducktypist.com/">http://ducktypist.com/</a></p>
<p> LRTHW 中文版是 <a href="http://blog.xdite.net"> xdite</a> 基於 LPTHW 中文版的翻譯成果,改編成 Ruby 版,並修正當中繁簡以及不同程式( Python / Ruby )環境所造成的差異改譯而成。</p>
<p>如果你對 LRTHW 的翻譯有任何意見和建議,請在這個 <a href="http://github.com/lrthw/lrthw.github.com/">project</a> 的 Github issue 頁發 issue 給我,或者是直接 pull request 也行。</p>
<p>你也可以上 <a href="http://ruby.learncodethehardway.org/">LRTHW 官網</a> 購買本書正版,這也是對 Zed Shaw 的支持。</p>
</article>
<article>
<h3><a href="/intro/">笨方法更簡單</a></h3>
</article>
<article>
<h3><a href="/ex00/">習題 0: 準備工作</a></h3>
</article>
<article>
<h3><a href="/ex01/">習題 1: 第一個程式</a></h3>
</article>
<article>
<h3><a href="/ex02/">習題 2: 註釋和井號</a></h3>
</article>
<article>
<h3><a href="/ex03/">習題 3: 數字和數學計算</a></h3>
</article>
<article>
<h3><a href="/ex04/">習題 4: 變數(variable)和命名</a></h3>
</article>
<article>
<h3><a href="/ex05/">習題 5: 更多的變數和印出</a></h3>
</article>
<article>
<h3><a href="/ex06/">習題 6: 字串(string)和文字</a></h3>
</article>
<article>
<h3><a href="/ex07/">習題 7: 更多印出</a></h3>
</article>
<article>
<h3><a href="/ex08/">習題 8: 印出,印出</a></h3>
</article>
<article>
<h3><a href="/ex09/">習題 9: 印出,印出,印出</a></h3>
</article>
<article>
<h3><a href="/ex10/">習題 10: 那是什麼?</a></h3>
</article>
<article>
<h3><a href="/ex11/">習題 11: 提問</a></h3>
</article>
<article>
<h3><a href="/ex12/">習題 12: 模組 (Module)</a></h3>
</article>
<article>
<h3><a href="/ex13/">習題 13: 参数、解包、參數</a></h3>
</article>
<article>
<h3><a href="/ex14/">習題 14: 提示和傳遞</a></h3>
</article>
<article>
<h3><a href="/ex15/">習題 15: 讀取檔案</a></h3>
</article>
<article>
<h3><a href="/ex16/">習題 16: 讀寫檔案</a></h3>
</article>
<article>
<h3><a href="/ex17/">習題 17: 更多的檔案操作</a></h3>
</article>
<article>
<h3><a href="/ex18/">習題 18: 命名、變數、程式碼、函式</a></h3>
</article>
<article>
<h3><a href="/ex19/">習題 19: 函式和變數</a></h3>
</article>
<article>
<h3><a href="/ex20/">習題 20: 函式和檔案</a></h3>
</article>
<article>
<h3><a href="/ex21/">習題 21: 函式可以傳回東西</a></h3>
</article>
<article>
<h3><a href="/ex22/">習題 22: 到現在你學到了哪些東西?</a></h3>
</article>
<article>
<h3><a href="/ex23/">習題 23: 閱讀一些程式碼</a></h3>
</article>
<article>
<h3><a href="/ex24/">習題 24: 更多練習</a></h3>
</article>
<article>
<h3><a href="/ex25/">習題 25: 更多更多的練習</a></h3>
</article>
<article>
<h3><a href="/ex26/">習題 26: 恭喜你,現在來考試了!</a></h3>
</article>
<article>
<h3><a href="/ex27/">習題 27: 記住邏輯關係</a></h3>
</article>
<article>
<h3><a href="/ex28/">習題 28: 布林(Boolean)表示式練習</a></h3>
</article>
<article>
<h3><a href="/ex29/">習題 29: 如果(If)</a></h3>
</article>
<article>
<h3><a href="/ex30/">習題 30: Else 和 If</a></h3>
</article>
<article>
<h3><a href="/ex31/">習題 31: 做出決定</a></h3>
</article>
<article>
<h3><a href="/ex32/">習題 32: 迴圈和陣列</a></h3>
</article>
<article>
<h3><a href="/ex33/">習題 33: While 迴圈</a></h3>
</article>
<article>
<h3><a href="/ex34/">習題 34: 存取陣列裡的元素</a></h3>
</article>
<article>
<h3><a href="/ex35/">習題 35: 分支 (Branches) 和函式 (Functions)</a></h3>
</article>
<article>
<h3><a href="/ex36/">習題 36: 設計和測試</a></h3>
</article>
<article>
<h3><a href="/ex37/">習題 37: 複習各種符號</a></h3>
</article>
<article>
<h3><a href="/ex38/">習題 38: 閱讀程式碼</a></h3>
</article>
<article>
<h3><a href="/ex39/">習題 39: 陣列的操作</a></h3>
</article>
<article>
<h3><a href="/ex40/">習題 40: Hash, 可愛的 Hash</a></h3>
</article>
<article>
<h3><a href="/ex41/">習題 41: 來自 Percal 25 號行星的哥頓人(Gothons)</a></h3>
</article>
<article>
<h3><a href="/ex42/">習題 42: 物以類聚</a></h3>
</article>
<article>
<h3><a href="/ex43/">習題 43: 你來製作一個遊戲</a></h3>
</article>
<article>
<h3><a href="/ex44/">習題 44: 評估你的遊戲</a></h3>
</article>
<article>
<h3><a href="/ex45/">習題 45: 物件、類和從屬關係</a></h3>
</article>
<article>
<h3><a href="/ex46/">習題 46: 一個專案骨架</a></h3>
</article>
<article>
<h3><a href="/ex47/">習題 47: 自動化測試</a></h3>
</article>
<article>
<h3><a href="/ex48/">習題 48: 更進階的使用者輸入</a></h3>
</article>
<article>
<h3><a href="/ex49/">習題 49: 創造句子</a></h3>
</article>
<article>
<h3><a href="/ex50/">習題 50: 你的第一個網站</a></h3>
</article>
<article>
<h3><a href="/ex51/">習題 51: 從瀏覽器中取得輸入</a></h3>
</article>
<article>
<h3><a href="/ex52/">習題 52: 創造你的網頁遊戲</a></h3>
</article>
<article>
<h3><a href="/next/">下一步</a></h3>
</article>
<article>
<h3><a href="/advice/">一個老程式設計師的建議</a></h3>
</article>
</div>
<aside class="sidebar">
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="/intro/">笨方法更簡單</a>
</li>
<li class="post">
<a href="/ex00/">習題 0: 準備工作</a>
</li>
<li class="post">
<a href="/ex01/">習題 1: 第一個程式</a>
</li>
<li class="post">
<a href="/ex02/">習題 2: 註釋和井號</a>
</li>
<li class="post">
<a href="/ex03/">習題 3: 數字和數學計算</a>
</li>
<li class="post">
<a href="/ex04/">習題 4: 變數(variable)和命名</a>
</li>
<li class="post">
<a href="/ex05/">習題 5: 更多的變數和印出</a>
</li>
<li class="post">
<a href="/ex06/">習題 6: 字串(string)和文字</a>
</li>
<li class="post">
<a href="/ex07/">習題 7: 更多印出</a>
</li>
<li class="post">
<a href="/ex08/">習題 8: 印出,印出</a>
</li>
<li class="post">
<a href="/ex09/">習題 9: 印出,印出,印出</a>
</li>
<li class="post">
<a href="/ex10/">習題 10: 那是什麼?</a>
</li>
<li class="post">
<a href="/ex11/">習題 11: 提問</a>
</li>
<li class="post">
<a href="/ex12/">習題 12: 模組 (Module)</a>
</li>
<li class="post">
<a href="/ex13/">習題 13: 参数、解包、參數</a>
</li>
<li class="post">
<a href="/ex14/">習題 14: 提示和傳遞</a>
</li>
<li class="post">
<a href="/ex15/">習題 15: 讀取檔案</a>
</li>
<li class="post">
<a href="/ex16/">習題 16: 讀寫檔案</a>
</li>
<li class="post">
<a href="/ex17/">習題 17: 更多的檔案操作</a>
</li>
<li class="post">
<a href="/ex18/">習題 18: 命名、變數、程式碼、函式</a>
</li>
<li class="post">
<a href="/ex19/">習題 19: 函式和變數</a>
</li>
<li class="post">
<a href="/ex20/">習題 20: 函式和檔案</a>
</li>
<li class="post">
<a href="/ex21/">習題 21: 函式可以傳回東西</a>
</li>
<li class="post">
<a href="/ex22/">習題 22: 到現在你學到了哪些東西?</a>
</li>
<li class="post">
<a href="/ex23/">習題 23: 閱讀一些程式碼</a>
</li>
<li class="post">
<a href="/ex24/">習題 24: 更多練習</a>
</li>
<li class="post">
<a href="/ex25/">習題 25: 更多更多的練習</a>
</li>
<li class="post">
<a href="/ex26/">習題 26: 恭喜你,現在來考試了!</a>
</li>
<li class="post">
<a href="/ex27/">習題 27: 記住邏輯關係</a>
</li>
<li class="post">
<a href="/ex28/">習題 28: 布林(Boolean)表示式練習</a>
</li>
<li class="post">
<a href="/ex29/">習題 29: 如果(If)</a>
</li>
<li class="post">
<a href="/ex30/">習題 30: Else 和 If</a>
</li>
<li class="post">
<a href="/ex31/">習題 31: 做出決定</a>
</li>
<li class="post">
<a href="/ex32/">習題 32: 迴圈和陣列</a>
</li>
<li class="post">
<a href="/ex33/">習題 33: While 迴圈</a>
</li>
<li class="post">
<a href="/ex34/">習題 34: 存取陣列裡的元素</a>
</li>
<li class="post">
<a href="/ex35/">習題 35: 分支 (Branches) 和函式 (Functions)</a>
</li>
<li class="post">
<a href="/ex36/">習題 36: 設計和測試</a>
</li>
<li class="post">
<a href="/ex37/">習題 37: 複習各種符號</a>
</li>
<li class="post">
<a href="/ex38/">習題 38: 閱讀程式碼</a>
</li>
<li class="post">
<a href="/ex39/">習題 39: 陣列的操作</a>
</li>
<li class="post">
<a href="/ex40/">習題 40: Hash, 可愛的 Hash</a>
</li>
<li class="post">
<a href="/ex41/">習題 41: 來自 Percal 25 號行星的哥頓人(Gothons)</a>
</li>
<li class="post">
<a href="/ex42/">習題 42: 物以類聚</a>
</li>
<li class="post">
<a href="/ex43/">習題 43: 你來製作一個遊戲</a>
</li>
<li class="post">
<a href="/ex44/">習題 44: 評估你的遊戲</a>
</li>
<li class="post">
<a href="/ex45/">習題 45: 物件、類和從屬關係</a>
</li>
<li class="post">
<a href="/ex46/">習題 46: 一個專案骨架</a>
</li>
<li class="post">
<a href="/ex47/">習題 47: 自動化測試</a>
</li>
<li class="post">
<a href="/ex48/">習題 48: 更進階的使用者輸入</a>
</li>
<li class="post">
<a href="/ex49/">習題 49: 創造句子</a>
</li>
<li class="post">
<a href="/ex50/">習題 50: 你的第一個網站</a>
</li>
<li class="post">
<a href="/ex51/">習題 51: 從瀏覽器中取得輸入</a>
</li>
<li class="post">
<a href="/ex52/">習題 52: 創造你的網頁遊戲</a>
</li>
<li class="post">
<a href="/next/">下一步</a>
</li>
<li class="post">
<a href="/advice/">一個老程式設計師的建議</a>
</li>
</ul>
</section>
<section>
<h1>Github Repos</h1>
<ul id="gh_repos">
<li class="loading">Status updating…</li>
</ul>
<a href="https://github.com/lrthw">@lrthw</a> on Github
<script type="text/javascript">
$.domReady(function(){
if (!window.jXHR){
var jxhr = document.createElement('script');
jxhr.type = 'text/javascript';
jxhr.src = '/javascripts/libs/jXHR.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(jxhr, s);
}
github.showRepos({
user: 'lrthw',
count: 0,
skip_forks: true,
target: '#gh_repos'
});
});
</script>
<script src="/javascripts/github.js" type="text/javascript"> </script>
</section>
<section>
<h1>Latest Tweets</h1>
<ul id="tweets">
<li class="loading">Status updating…</li>
</ul>
<script type="text/javascript">
$.domReady(function(){
getTwitterFeed("xdite", 4, false);
});
</script>
<script src="/javascripts/twitter.js" type="text/javascript"> </script>
<a href="http://twitter.com/xdite" class="twitter-follow-button" data-width="208px" data-show-count="false">Follow @xdite</a>
</section>
</aside>
</div>
</div>
<footer role="contentinfo"><p>
Copyright © 2011 - xdite -
<span class="credit">Powered by <a href="http://octopress.org">Octopress</a></span>
</p>
</footer>
<script type="text/javascript">
var disqus_shortname = 'learnrubythehardway';
var disqus_script = 'count.js';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/' + disqus_script;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
</script>
<script type="text/javascript">
(function() {
var script = document.createElement('script'); script.type = 'text/javascript'; script.async = true;
script.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(script, s);
})();
</script>
<script type="text/javascript">
(function(){
var twitterWidgets = document.createElement('script');
twitterWidgets.type = 'text/javascript';
twitterWidgets.async = true;
twitterWidgets.src = 'http://platform.twitter.com/widgets.js';
document.getElementsByTagName('head')[0].appendChild(twitterWidgets);
})();
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-537077-9']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>