100% found this document useful (1 vote)
15 views

Programming Ruby 1 9 2 0 The Pragmatic Programmers Guide Fourth Edition Dave Thomas pdf download

The document provides information about the book 'Programming Ruby 1.9 & 2.0: The Pragmatic Programmer's Guide' by Dave Thomas, including download links and details about its content. It covers various aspects of Ruby programming, including object-oriented concepts, standard types, and unit testing. The document also lists additional programming resources and books available for download.

Uploaded by

kanariatkia
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
15 views

Programming Ruby 1 9 2 0 The Pragmatic Programmers Guide Fourth Edition Dave Thomas pdf download

The document provides information about the book 'Programming Ruby 1.9 & 2.0: The Pragmatic Programmer's Guide' by Dave Thomas, including download links and details about its content. It covers various aspects of Ruby programming, including object-oriented concepts, standard types, and unit testing. The document also lists additional programming resources and books available for download.

Uploaded by

kanariatkia
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

Programming Ruby 1 9 2 0 The Pragmatic

Programmers Guide Fourth Edition Dave Thomas pdf


download

https://ebookfinal.com/download/programming-ruby-1-9-2-0-the-
pragmatic-programmers-guide-fourth-edition-dave-thomas/

Explore and download more ebooks or textbooks


at ebookfinal.com
We have selected some products that you may be interested in
Click the link to download now or visit ebookfinal.com
for more options!.

Agile web development with rails a Pragmatic guide 1st


Edition Dave Thomas

https://ebookfinal.com/download/agile-web-development-with-rails-a-
pragmatic-guide-1st-edition-dave-thomas/

FXRuby Create Lean and Mean GUIs with Ruby Pragmatic


Programmers 1st Edition Lyle Johnson

https://ebookfinal.com/download/fxruby-create-lean-and-mean-guis-with-
ruby-pragmatic-programmers-1st-edition-lyle-johnson/

SAS Certification Prep Guide Advanced Programming for SAS


9 Fourth Edition Sas Institute

https://ebookfinal.com/download/sas-certification-prep-guide-advanced-
programming-for-sas-9-fourth-edition-sas-institute/

Pragmatic Unit Testing in C with NUnit Pragmatic


Programmers 1st Edition Andy Hunt

https://ebookfinal.com/download/pragmatic-unit-testing-in-c-with-
nunit-pragmatic-programmers-1st-edition-andy-hunt/
Programming Java 2 micro edition on Symbian OS a developer
s guide to MIDP 2 0 Martin De Jode

https://ebookfinal.com/download/programming-java-2-micro-edition-on-
symbian-os-a-developer-s-guide-to-midp-2-0-martin-de-jode/

Maple 9 advanced programming guide 1st Edition Monagan

https://ebookfinal.com/download/maple-9-advanced-programming-
guide-1st-edition-monagan/

Base SAS 9 1 Procedures Guide Volumes 1 2 3 and 4 1st


Edition Sas Institute

https://ebookfinal.com/download/base-sas-9-1-procedures-guide-
volumes-1-2-3-and-4-1st-edition-sas-institute/

Essential XNA Game Studio 2 0 Programming 1st Edition Jim


Perry

https://ebookfinal.com/download/essential-xna-game-
studio-2-0-programming-1st-edition-jim-perry/

Ruby Programming 1st Edition Jerry Lee Ford

https://ebookfinal.com/download/ruby-programming-1st-edition-jerry-
lee-ford/
Programming Ruby 1 9 2 0 The Pragmatic Programmers
Guide Fourth Edition Dave Thomas Digital Instant
Download
Author(s): Dave Thomas, Andy Hunt, Chad Fowler
ISBN(s): 9781937785499, 1937785491
Edition: Fourth Edition
File Details: PDF, 16.05 MB
Year: 2013
Language: english
Download from Wow! eBook <www.wowebook.com>
Download from Wow! eBook <www.wowebook.com>
Programming Ruby 1.9 & 2.0
The Pragmatic Programmers’ Guide

Dave Thomas
with Chad Fowler
Andy Hunt

The Pragmatic Bookshelf


Dallas, Texas • Raleigh, North Carolina

Download from Wow! eBook <www.wowebook.com>


Many of the designations used by manufacturers and sellers to distinguish their products are claimed
as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC
was aware of a trademark claim, the designations have been printed in initial capital letters or in all
capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic
Bookshelf, PragProg and the linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no re-
sponsibility for errors or omissions, or for damages that may result from the use of information (in-
cluding program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team create better
software and have more fun. For more information, as well as the latest Pragmatic titles, please visit
us at http://pragprog.com.
The team that produced this book includes:
Janet Furlow (producer)
Juliet Benda (rights)
Ellie Callahan (support)

Copyright © 2013 The Pragmatic Programmers, LLC.


All rights reserved.

No part of this publication may be reproduced, stored in a retrieval system, or


transmitted, in any form, or by any means, electronic, mechanical, photocopying,
recording, or otherwise, without the prior consent of the publisher.

Printed in the United States of America.


ISBN-13: 978-1-93778-549-9
Encoded using the finest acid-free high-entropy binary digits.
Book version: P1.0—June, 2013

Download from Wow! eBook <www.wowebook.com>


Contents
Foreword to the Third Edition . . . . . . . . . . ix

Preface . . . . . . . . . . . . . . . . xi

Road Map . . . . . . . . . . . . . . . xv

Part I — Facets of Ruby


1. Getting Started . . . . . . . . . . . . . . 3
1.1 The Command Prompt 3
1.2 Installing Ruby 5
1.3 Running Ruby 9
1.4 Ruby Documentation: RDoc and ri 11

2. Ruby.new . . . . . . . . . . . . . . . 15
2.1 Ruby Is an Object-Oriented Language 15
2.2 Some Basic Ruby 17
2.3 Arrays and Hashes 20
2.4 Symbols 21
2.5 Control Structures 23
2.6 Regular Expressions 24
2.7 Blocks and Iterators 25
2.8 Reading and ’Riting 27
2.9 Command-Line Arguments 28
2.10 Onward and Upward 28

3. Classes, Objects, and Variables . . . . . . . . . . 29


3.1 Objects and Attributes 32
3.2 Classes Working with Other Classes 37
3.3 Access Control 40
3.4 Variables 43

4. Containers, Blocks, and Iterators . . . . . . . . . . 45


4.1 Arrays 45
4.2 Hashes 47
4.3 Blocks and Iterators 52
4.4 Containers Everywhere 68

Download from Wow! eBook <www.wowebook.com>


Contents • iv

5. Sharing Functionality: Inheritance, Modules, and Mixins . . . . 69


5.1 Inheritance and Messages 69
5.2 Modules 73
5.3 Mixins 75
5.4 Iterators and the Enumerable Module 77
5.5 Composing Modules 77
5.6 Inheritance, Mixins, and Design 80

6. Standard Types . . . . . . . . . . . . . . 83
6.1 Numbers 83
6.2 Strings 86
6.3 Ranges 90

7. Regular Expressions . . . . . . . . . . . . . 93
7.1 What Regular Expressions Let You Do 93
7.2 Ruby’s Regular Expressions 94
7.3 Digging Deeper 96
7.4 Advanced Regular Expressions 105

8. More About Methods . . . . . . . . . . . . 115


8.1 Defining a Method 115
8.2 Calling a Method 118

9. Expressions . . . . . . . . . . . . . . 125
9.1 Operator Expressions 126
9.2 Miscellaneous Expressions 127
9.3 Assignment 128
9.4 Conditional Execution 132
9.5 case Expressions 136
9.6 Loops 138
9.7 Variable Scope, Loops, and Blocks 142

10. Exceptions, catch, and throw . . . . . . . . . . 145


10.1 The Exception Class 145
10.2 Handling Exceptions 146
10.3 Raising Exceptions 150
10.4 catch and throw 151

11. Basic Input and Output . . . . . . . . . . . . 153


11.1 What Is an IO Object? 153
11.2 Opening and Closing Files 153
11.3 Reading and Writing Files 154
11.4 Talking to Networks 158
11.5 Parsing HTML 159

12. Fibers, Threads, and Processes . . . . . . . . . . 161


12.1 Fibers 161
12.2 Multithreading 163
12.3 Controlling the Thread Scheduler 167

Download from Wow! eBook <www.wowebook.com>


Contents •v

12.4 Mutual Exclusion 167


12.5 Running Multiple Processes 170

13. Unit Testing . . . . . . . . . . . . . . 175


13.1 The Testing Framework 177
13.2 Structuring Tests 181
13.3 Organizing and Running Tests 183
13.4 RSpec and Shoulda 186
13.5 Test::Unit assertions 193

14. When Trouble Strikes! . . . . . . . . . . . . 195


14.1 Ruby Debugger 195
14.2 Interactive Ruby 196
14.3 Editor Support 197
14.4 But It Doesn’t Work! 198
14.5 But It’s Too Slow! 201

Part II — Ruby in Its Setting


15. Ruby and Its World . . . . . . . . . . . . 209
15.1 Command-Line Arguments 209
15.2 Program Termination 214
15.3 Environment Variables 214
15.4 Where Ruby Finds Its Libraries 216
15.5 RubyGems Integration 217
15.6 The Rake Build Tool 222
15.7 Build Environment 224

16. Namespaces, Source Files, and Distribution . . . . . . . 225


16.1 Namespaces 225
16.2 Organizing Your Source 226
16.3 Distributing and Installing Your Code 233

17. Character Encoding . . . . . . . . . . . . 239


17.1 Encodings 240
17.2 Source Files 240
17.3 Transcoding 245
17.4 Input and Output Encoding 246
17.5 Default External Encoding 248
17.6 Encoding Compatibility 249
17.7 Default Internal Encoding 250
17.8 Fun with Unicode 251

18. Interactive Ruby Shell . . . . . . . . . . . . 253


18.1 Command Line 253
18.2 Commands 260

19. Documenting Ruby . . . . . . . . . . . . 263


19.1 Adding RDoc to Ruby Code 266
19.2 Adding RDoc to C Extensions 269

Download from Wow! eBook <www.wowebook.com>


Contents • vi

19.3 Running RDoc 271


19.4 Ruby source file documented with RDoc 272
19.5 C source file documented with RDoc 274

20. Ruby and the Web . . . . . . . . . . . . . 277


20.1 Writing CGI Scripts 277
20.2 Using cgi.rb 277
20.3 Templating Systems 280
20.4 Cookies 284
20.5 Choice of Web Servers 286
20.6 Frameworks 287

21. Ruby and Microsoft Windows . . . . . . . . . . 289


21.1 Running Ruby Under Windows 289
21.2 Win32API 289
21.3 Windows Automation 290

Part III — Ruby Crystallized


22. The Ruby Language . . . . . . . . . . . . 297
22.1 Source File Encoding 297
22.2 Source Layout 297
22.3 The Basic Types 299
22.4 Names 306
22.5 Variables and Constants 308
22.6 Expressions, Conditionals, and Loops 316
22.7 Method Definition 323
22.8 Invoking a Method 327
22.9 Aliasing 330
22.10 Class Definition 331
22.11 Module Definitions 333
22.12 Access Control 335
22.13 Blocks, Closures, and Proc Objects 335
22.14 Exceptions 339
22.15 catch and throw 341

23. Duck Typing . . . . . . . . . . . . . . 343


23.1 Classes Aren’t Types 344
23.2 Coding like a Duck 348
23.3 Standard Protocols and Coercions 349
23.4 Walk the Walk, Talk the Talk 355

24. Metaprogramming . . . . . . . . . . . . . 357


24.1 Objects and Classes 357
24.2 Singletons 360
24.3 Inheritance and Visibility 365
24.4 Modules and Mixins 366
24.5 Metaprogramming Class-Level Macros 372
24.6 Two Other Forms of Class Definition 377

Download from Wow! eBook <www.wowebook.com>


Contents • vii

24.7 instance_eval and class_eval 379


24.8 Hook Methods 383
24.9 One Last Example 388
24.10 Top-Level Execution Environment 390
24.11 The Turtle Graphics Program 391

25. Reflection, ObjectSpace, and Distributed Ruby . . . . . . 393


25.1 Looking at Objects 393
25.2 Looking at Classes 394
25.3 Calling Methods Dynamically 396
25.4 System Hooks 398
25.5 Tracing Your Program’s Execution 400
25.6 Behind the Curtain: The Ruby VM 402
25.7 Marshaling and Distributed Ruby 403
25.8 Compile Time? Runtime? Anytime! 408

26. Locking Ruby in the Safe . . . . . . . . . . . 409


26.1 Safe Levels 410
26.2 Tainted Objects 410
26.3 Trusted Objects 411
26.4 Definition of the safe levels 412

Part IV — Ruby Library Reference


27. Built-in Classes and Modules . . . . . . . . . . 417

28. Standard Library . . . . . . . . . . . . . 729

A1. Support . . . . . . . . . . . . . . . 829


A1.1 Web Sites 829
A1.2 Usenet Newsgroup 830
A1.3 Mailing Lists 830
A1.4 Bug Reporting 830

A2. Bibliography . . . . . . . . . . . . . . 831

Index . . . . . . . . . . . . . . . . 833

Download from Wow! eBook <www.wowebook.com>


Foreword to the Third Edition
I wrote forewords to the previous two editions of this book. For the first edition, I wrote
about motivation. For the second edition, I wrote about miracles.
For this third edition, I’d like to write about courage. I always admire brave people. People
around Ruby seem to be brave, like the authors of this book. They were brave to jump in to
a relatively unknown language like Ruby. They were brave to try new technology. They
could have happily stayed with an old technology, but they didn’t. They built their own
world using new bricks and mortar. They were adventurers, explorers, and pioneers. By
their effort, we have a fruitful result—Ruby.
Now, I feel that I’ve created my own universe with help from those brave people. At first, I
thought it was a miniature universe, like the one in “Fessenden’s Worlds.” But now it seems
like a real universe. Countless brave people are now working with Ruby. They challenge
new things every day, trying to make the world better and bigger. I am very glad I am part
of the Ruby world.
I suppose that even the world itself could not contain the books that should be written. But
now we have the first book, updated to the most recent. Enjoy.

Yukihiro Matsumoto, aka “Matz”


Japan, February 2009

Download from Wow! eBook <www.wowebook.com> report erratum • discuss


Preface
This book is a new version of the PickAxe, as Programming Ruby is known to Ruby program-
mers. It is a tutorial and reference for versions 1.9 and 2.0 of the Ruby programming language.
Ruby 1.9 was a significant departure from previous versions. There are major changes in
string handling, the scoping of block variables, and the threading model. It has a new virtual
machine. The built-in libraries have grown, adding many hundreds of new methods and
almost a dozen new classes. The language now supports scores of character encodings,
making Ruby one of the only programming languages to live fully in the whole world.
Ruby 2.0 is a (fairly minor) incremental improvement on Ruby 1.9.

Why Ruby?
When Andy and I wrote the first edition, we had to explain the background and appeal of
Ruby. Among other things, we wrote, “When we discovered Ruby, we realized that we’d
found what we’d been looking for. More than any other language with which we have
worked, Ruby stays out of your way. You can concentrate on solving the problem at hand,
instead of struggling with compiler and language issues. That’s how it can help you become
a better programmer: by giving you the chance to spend your time creating solutions for
your users, not for the compiler.”
That belief is even stronger today. More than thirteen years later, Ruby is still my language
of choice: I use it for client applications and web applications. I use it to run our publishing
business (our online store, http://pragprog.com, is more than 40,000 lines of Rails code), and I
use it for all those little programming jobs I do just to get things running smoothly.
In all those years, Ruby has progressed nicely. A large number of methods have been added
to the built-in classes and modules, and the size of the standard library (those libraries
included in the Ruby distribution) has grown tremendously. The community now has a
standard documentation system (RDoc), and RubyGems has become the system of choice
for packaging Ruby code for distribution. We have a best-of-breed web application frame-
work, Ruby on Rails, with others waiting in the wings. We are leading the world when it
comes to testing, with tools such as RSpec and Cucumber, and we’re working through the
hard problems of packaging and dependency management. We’ve matured nicely.
But Ruby is older than that. The first release of this book happened on Ruby’s 20th birthday
(it was created on February 24, 1993). The release of Ruby 2.0 is a celebration of that
anniversary.

Download from Wow! eBook <www.wowebook.com> report erratum • discuss


Preface • xii

Ruby Versions
1
This version of the PickAxe documents both Ruby 2.0 and Ruby 1.9.3.
Exactly what version of Ruby did I use to write this book? Let’s ask Ruby:
$ ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0]

This illustrates an important point. Most of the code samples you see in this book are actually
executed each time I format the book. When you see some output from a program, that
output was produced by running the code and inserting the results into the book.

Changes in the Book


Throughout the book I’ve tried to mark differences between Ruby 1.9 and 2.0 using a small
symbol, like the one here. If you’re reading this as an ebook, you’ll see little arrows next to
New in 2.0⇣ this flag. Clicking those will take you to the next or previous 2.0 change. One change I didn’t
make: I decided to continue to use the word we when talking about the authors in the body
of the book. Many of the words come from the first edition, and I certainly don’t want to
claim any credit for Andy’s work on that book.

Changes in the Ruby 2.0 Printing


Compared to the major change that occurred between Ruby 1.8 and Ruby 1.9, the update to
Ruby 2 is fairly gentle. This book documents all the updated builtin class changes and the
new keyword arguments. It spends some time looking at lazy enumerators, and at the
updates to the regular expression engine. But, in general, users of Ruby 1.9 will feel right at
home, and folks still using Ruby 1.8 should consider skipping straight to Ruby 2.

Resources
Visit the Ruby website at http://www.ruby-lang.org to see what’s new. Chat with other Ruby
users on the newsgroup or mailing lists (see Appendix 1, Support, on page 829).
And I’d certainly appreciate hearing from you. Comments, suggestions, errors in the text,
and problems in the examples are all welcome. Email us at rubybook@pragprog.com.
2
If you find errors in the book, you can add them to the errata page. If you’re reading the
PDF version of the book, you can also report an erratum by clicking the link in the page
footers.
You’ll find links to the source code for almost all the book’s example code at http://www.prag-
prog.com/titles/ruby4.

1. Ruby version numbering used to follow the same scheme used for many other open source projects.
Releases with even minor version numbers—1.6, 1.8, and so on—were stable, public releases. These
are the releases that are prepackaged and made available on the various Ruby websites. Development
versions of the software had odd minor version numbers, such as 1.5 and 1.7. However, in 2007 Matz
broke with convention and made 1.9 a stable public release of Ruby.
2. http://www.pragprog.com/titles/ruby4/errata.html

Download from Wow! eBook <www.wowebook.com> report erratum • discuss


Acknowledgments • xiii

Acknowledgments
The first International Ruby Conference had something like 32 attendees. We could all fit
into the tiny hotel bar and talk the night away. Things have changed. The annual conference
now sells out many hundreds of seats within hours, and an increasing number of secondary
conferences have sprung up to meet the needs of folks who can’t get to RubyConf.
As the community has grown, so has Ruby. The language and its libraries are now many
times bigger than they were back when the first edition of this book came out.
And as the language has grown, so has this book. The PickAxe is now massive, mostly
because I still want to document every single built-in class, module, and method. But a book
of this size can never be a solo undertaking. This edition builds on the work from the first
two editions, which included major contributions from Chad Fowler and Andy Hunt. Just
as significant, all three editions have been works created by the Ruby community. On the
mailing lists, in the forums, and on this book’s errata pages, hundreds of people have con-
tributed ideas, code, and corrections to make it better. As always, I owe every one of you a
big “thank you!” for all you have done and for all that you do. The Ruby community is still
as vibrant, interesting, and (mostly) friendly as it ever was—that’s quite an achievement
given the explosive growth we’ve enjoyed.
For the third (tenth anniversary) printing, Wayne E. Seguin was kind enough to check the
section on the wonderful tool RVM, and Luis Lavena checked the section on installing under
Windows, as well as the chapter on running Ruby on Windows. And I’d like to call Anthony
Burns a hero for doing an amazing job of reading through the changes as I was writing them,
3
but that would take away from the fact that he’s a true hero.
Getting this book into production has also been a challenge. Kim Wimpsett is the world’s
best copy editor—she’s the only copy editor I know who finds errors in code and fixes XML
markup. Any remaining errors in this book are a result of my mistyping her suggested cor-
rections. And, as we raced to get the book to the printer in time for RubyConf X, Janet Furlow
patiently kept us all on track.
Finally, I’m still deeply indebted to Yukihiro “Matz” Matsumoto, the creator of Ruby.
Throughout this prolonged period of growth and change, he has remained helpful, cheery,
and dedicated to polishing this gem of a language. The friendly and open spirit of the Ruby
community is a direct reflection of the person at its center.
Thank you all. Domo arigato gozaimasu.

Dave Thomas
The Pragmatic Programmers
dave@pragprog.com
June 2013

3. http://www.flickr.com/photos/pragdave/sets/72157625046498937/

Download from Wow! eBook <www.wowebook.com> report erratum • discuss


Preface • xiv

Notation Conventions
Literal code examples are shown using a sans-serif font:
class SampleCode
def run
#...
end
end

Within the text, Fred#do_something is a reference to an instance method (in this case the method
4
do_something) of class Fred, Fred.new is a class method, and Fred::EOF is a class constant. The
decision to use a hash character to indicate instance methods was a tough one. It isn’t valid
Ruby syntax, but we thought that it was important to differentiate between the instance and
class methods of a particular class. When you see us write File.read, you know we’re talking
about the class method read. When instead we write File#read, we’re referring to the instance
method read. This convention is now standard in most Ruby discussions and documentation.
This book contains many snippets of Ruby code. Where possible, we’ve tried to show what
happens when they run. In simple cases, we show the value of expressions on the same line
as the expression. Here’s an example:
a = 1
b = 2
a + b # => 3

Here, you can see that the result of evaluating a + b is the value 3, shown to the right of the
arrow. Note that if you were to run this program, you wouldn’t see the value 3 output—
you’d need to use a method such as puts to write it out.
At times, we’re also interested in the values of assignment statements:
a = 1 # => 1
a + 2 # => 3

If the program produces more complex output, we show it after the program code:
3.times { puts "Hello!" }
produces:
Hello!
Hello!
Hello!

In some of the library documentation, we wanted to show where spaces appear in the output.
You’ll see these spaces as ␣ characters.
Command-line invocations are shown with literal text in a regular font, and parameters you
supply are shown in an italic font. Optional elements are shown in brackets.
ruby ‹ flags ›* progname ‹ arguments ›*

4. In some other Ruby documentation, you may see class methods written as Fred::new. This is perfectly
valid Ruby syntax; we just happen to think that Fred.new is less distracting to read.

Download from Wow! eBook <www.wowebook.com> report erratum • discuss


Road Map
The main text of this book has four separate parts, each with its own personality and each
addressing different aspects of the Ruby language.
In Part I, Facets of Ruby, you’ll find a Ruby tutorial. It starts with some notes on getting Ruby
running on your system followed by a short chapter on some of the terminology and concepts
that are unique to Ruby. This chapter also includes enough basic syntax so that the other
chapters will make sense. The rest of the tutorial is a top-down look at the language. There
we talk about classes and objects, types, expressions, and all the other things that make up
the language. We end with chapters on unit testing and digging yourself out when trouble
strikes.
One of the great things about Ruby is how well it integrates with its environment. Part II,
Ruby in Its Setting, investigates this. Here you’ll find practical information on using Ruby:
using the interpreter options, using irb, documenting your Ruby code, and packaging your
Ruby gems so that others can enjoy them. You’ll also find tutorials on some common Ruby
tasks: using Ruby with the Web and using Ruby in a Microsoft Windows environment
(including wonderful things such as native API calls, COM integration, and Windows
Automation). We’ll also touch on using Ruby to access the Internet.
Part III, Ruby Crystallized, contains more advanced material. Here you’ll find all the gory
details about the language, the concept of duck typing, the object model, metaprogramming,
tainting, reflection, and marshaling. You could probably speed-read this the first time through,
but we think you’ll come back to it as you start to use Ruby in earnest.
The Ruby Library Reference is Part IV. It’s big. We document more than 1,300 methods in 57
built-in classes and modules (up from 800 methods in 40 classes and modules in the previous
edition). On top of that, we now document the library modules that are included in the
standard Ruby distribution (98 of them).
So, how should you read this book? Well, depending on your level of expertise with pro-
gramming in general and OO in particular, you may initially want to read just a few portions
of the book. Here are our recommendations.
If you’re a beginner, you may want to start with the tutorial material in Part I. Keep the
library reference close at hand as you start to write programs. Get familiar with the basic
classes such as Array, Hash, and String. As you become more comfortable in the environment,
you may want to investigate some of the more advanced topics in Part III.
If you’re already comfortable with Perl, Python, Java, or Smalltalk, then we suggest reading
Chapter 1, Getting Started, on page 3, which talks about installing and running Ruby, fol-
lowed by the introduction in Chapter 2, Ruby.new, on page 15. From there, you may want

Download from Wow! eBook <www.wowebook.com> report erratum • discuss


Road Map • xvi

to take the slower approach and keep going with the tutorial that follows, or you can skip
ahead to the gritty details starting in Part III, followed by the library reference in Part IV.
Experts, gurus, and “I-don’t-need-no-stinking-tutorial” types can dive straight into the lan-
guage reference in Chapter 22, The Ruby Language, on page 297; skim the library reference;
and then use the book as a (rather attractive) coffee coaster.
Of course, nothing is wrong with just starting at the beginning and working your way
through page by page.
And don’t forget, if you run into a problem that you can’t figure out, help is available. For
more information, see Appendix 1, Support, on page 829.

Download from Wow! eBook <www.wowebook.com> report erratum • discuss


Part I

Facets of Ruby

Download from Wow! eBook <www.wowebook.com>


CHAPTER 1

Getting Started
Before we start talking about the Ruby language, it would be useful if we helped you get
Ruby running on your computer. That way, you can try sample code and experiment on
your own as you read along. In fact, that’s probably essential if you want to learn Ruby—
get into the habit of writing code as you’re reading. We will also show you some different
ways to run Ruby.

1.1 The Command Prompt


(Feel free to skip to the next section if you’re already comfortable at your system’s command
prompt.)
Although there’s growing support for Ruby in IDEs, you’ll probably still end up spending
some time at your system’s command prompt, also known as a shell prompt or just plain
prompt. If you’re a Linux user, you’re probably already familiar with the prompt. If you don’t
already have a desktop icon for it, hunt around for an application called Terminal or xterm.
(On Ubuntu, you can navigate to it using Applications → Accessories → Terminal.) On
Windows, you’ll want to run cmd.exe, accessible by typing cmd into the dialog box that appears
when you select Start → Run. On OS X, run Applications → Utilities → Terminal.app.
In all three cases, a fairly empty window will pop up. It will contain a banner and a prompt.
Try typing echo hello at the prompt and hitting Enter (or Return, depending on your keyboard).
You should see hello echoed back, and another prompt should appear.

Directories, Folders, and Navigation


It is beyond the scope of this book to teach the commands available at the prompt, but we
do need to cover the basics of finding your way around.
If you’re used to a GUI tool such as Explorer on Windows or Finder on OS X for navigating
to your files, then you’ll be familiar with the idea of folders—locations on your hard drive
that can hold files and other folders.
When you’re at the command prompt, you have access to these same folders. But, somewhat
confusingly, at the prompt these folders are called directories (because they contain lists of
other directories and files). These directories are organized into a strict hierarchy. On Unix-
based systems (including OS X), there’s one top-level directory, called / (a forward slash).
On Windows, there is a top-level directory for each drive on your system, so you’ll find the
top level for your C: drive at C:\ (that’s the drive letter C, a colon, and a backslash).

Download from Wow! eBook <www.wowebook.com> report erratum • discuss


Chapter 1. Getting Started •4

The path to a file or directory is the set of directories that you have to traverse to get to it
from the top-level directory, followed by the name of the file or directory itself. Each compo-
nent in this name is separated by a forward slash (on Unix) or a backslash (on Windows).
So, if you organized your projects in a directory called projects under the top-level directory
and if the projects directory had a subdirectory for your time_planner project, the full path to
the README file would be /projects/time_planner/readme.txt on Unix and C:\projects\time_plan-
ner\readme.txt on Windows.

Spaces in Directory Names and Filenames


Most operating systems now allow you to create folders with spaces in their names. This is great when
you’re working at the GUI level. However, from the command prompt, spaces can be a headache,
because the shell that interprets what you type will treat the spaces in file and folder names as being
parameter separators and not as part of the name. You can get around this, but it generally isn’t worth
the hassle. If you are creating new folders and files, it’s easiest to avoid spaces in their names.

To navigate to a directory, use the cd command. (Because the Unix prompt varies from system
to system, we’ll just use a single dollar sign to represent it here.)
$ cd /projects/time_planner (on Unix)
C:\> cd \projects\time_planner (on Windows)

On Unix boxes, you probably don’t want to be creating top-level directories. Instead, Unix
gives each user their own home directory. So, if your username is dave, your home directory
might be located in /usr/dave, /home/dave, or /Users/dave. At the shell prompt, the special char-
acter ~ (a single tilde) stands for the path to your home directory. You can always change
directories to your home directory using cd ~, which can also be abbreviated to just cd.
To find out the directory you’re currently in, you can type pwd (on Unix) or cd on Windows.
So, for Unix users, you could type this:
$ cd /projects/time_planner
$ pwd
/projects/time_planner
$ cd
$ pwd
/Users/dave

On Windows, there’s no real concept of a user’s home directory:


C:\> cd \projects\time_planner
C:\projects\time_planner> cd \projects
C:\projects>

You can create a new directory under the current directory using the mkdir command:
$ cd /projects
$ mkdir expense_tracker
$ cd expense_tracker
$ pwd
/projects/expense_tracker

Notice that to change to the new directory, we could just give its name relative to the current
directory—we don’t have to enter the full path.

Download from Wow! eBook <www.wowebook.com> report erratum • discuss


Installing Ruby •5

We suggest you create a directory called pickaxe to hold the code you write while reading
this book:
$ mkdir ~/pickaxe (on Unix)
C:\> mkdir \pickaxe (on Windows)

Get into the habit of changing into that directory before you start work:
$ cd ~/pickaxe (on Unix)
C:\> cd \pickaxe (on Windows)

1.2 Installing Ruby


Ruby comes preinstalled on many Linux distributions, and Mac OS X includes Ruby (although
the version of Ruby that comes with OS X is normally several releases behind the current
Ruby version). Try typing ruby -v at a command prompt—you may be pleasantly surprised.
If you don’t already have Ruby on your system or if you’d like to upgrade to a newer version
(remembering that this book describes Ruby 1.9 and Ruby 2.0), you can install it pretty
simply. What you do next depends on your operating system.

Installing on Windows
There are two options for installing Ruby on Windows. The first is a simple installer pack-
age—download it, and you’ll have Ruby up and running in minutes. The second is slightly
more complex but gives you the flexibility of easily managing multiple Ruby environments
on the same computer at the same time. Whichever option you choose, you’ll first need to
download and install a working Ruby.

Install Ruby with RubyInstaller


The simple solution (and probably the right one to use if you’re not planning on running
multiple versions of Ruby at the same time) is Luis Lavena’s RubyInstaller.org.
Simply navigate to http://rubyinstaller.org, click the big DOWNLOAD button, and select the
Ruby version you want. Save the file to your downloads folder, and then run it once it has
downloaded. Click through the Windows nanny warnings, and you’ll come to a conventional
installer. Accept the defaults, and when the installer finishes, you’ll have an entry for Ruby
in your All Programs menu of the Start menu:

Select Start Command Prompt with Ruby to open a copy of the Windows command shell with
the environment set up to run Ruby.

Download from Wow! eBook <www.wowebook.com> report erratum • discuss


Discovering Diverse Content Through
Random Scribd Documents
balconies. In many of the churches into which I peeped Mass was in
progress, and the attendance was large of men as well as women.
In some of the streets the shops were handsome, though quite
small, while in the great arches between were caves, as it were,
where carriages and horses waited, apparently for hire, while in
others the cave had been fitted up as a café. The further one got
from the harbour, the finer were the shops and streets. In one I
saw a statue of Petrarch, and in another of Dante. The place is like
a rabbit warren, and just as populous. Priests and policemen were
everywhere. Here and there was a religious painting on the side of
a house, before which tapers were burning, and in one street I
observed a crucifix, to which the passers-by took off their hats. I
went into a café and watched some play at a billiard-table, much
smaller and with much bigger balls than those in use among us.
Omnibuses and tramcars abounded. Perpetual motion seemed to be
the order of the day. Some of my friends patronized the English
hotels, where the charges seemed to me dear. One thing, and one
thing only, amused me; I stumbled on a kind of eating-house; on the
outside was inscribed, Déjeuner à la fourchette, which was Englished
underneath as follows: ‘Breakfast to the fork.’ I did not enter. I
feared, as the English was so bad, that the cooking might be worse.
Altogether, my impression is that Naples looks best at a distance and
by moonlight, when a halo of soft light is thrown over bay and street
and mountain far away, and the hoarse cry of its thousand street-
sellers and cabmen and guides is unheard; when even the distant
tinkling of the bells of its many churches no longer reaches the ear;
when between you and the crowded city is a world of water calm
and still.
At Naples we took up more passengers and more mountains of
luggage. Our captain is in despair. That luggage question is the
terror of his life. He says that there would be no need of it if the
company would but establish a laundry on board; and why should
they not? It would be a great convenience to everyone, and save a
vast amount of trouble. The cabins are choked up with packages. It
would be as pleasant again for the passengers if they could have
their clothes washed on board.
I fear I did injustice to a dead royalty. I find, after all, it was simply
the fault of the company’s agent at Naples that most of us spent an
idle day in that far-famed city. The distinguished representative of
the distinguished Cook informed us that the Museum and Pompeii
were closed that day, because the agent of the company with whom
he came on board informed him such was the case. I find that they
were not, and that a small party of our fellow-travellers visited both
places; had lunch on shore, returned to the ship to dinner, and paid
a visit to the theatre in the evening for a sum under £1 per head.
As you may suppose, most of us were highly indignant at the
conduct of the company’s agent, and described him in terms that,
with the fear of the libel law in view, it may be dangerous for me to
report. I mention the fact that travellers may not be deceived by
what they hear on board, but go on shore and act for themselves.
Many of my fellow-travellers are Scotch. The Scotch, Mr. Charles
Reade tells us, are icebergs with volcanoes underneath, and we had
quite a volcano on board as we summed up the experiences of the
unfortunate day. I own it served me right, for, as a rule, I only
believe half that I hear. I ought to have started for Pompeii—by
myself, trusting to luck to get into the place. I am glad, however, to
be able to do justice to Cook and Sons, the friends of the traveller in
every part of the world. It is seldom that they make a blunder, or
their agents either.
In another respect I am not disappointed. ‘The grand object of
travelling,’ wrote Dr. Johnson, ‘is to see the shores of the
Mediterranean. On those shores were the four great empires of the
world—the Assyrian, the Persian, the Grecian, and the Roman. All
our religion—almost all our laws—almost all our arts—almost all that
sets us above savages has come to us from the shores of the
Mediterranean.’ To sail down the Mediterranean, past Capri—a
sunburnt rock—past Stromboli, through the Straits of Messina, over
the far-famed Scylla and Charybdis of the ancients, past Etna,
though unfortunately hidden from our vulgar gaze by the clouds of
night, is undoubtedly an immense treat. But the rest of the journey
is rather monotonous, though we were favoured by fine weather, a
fortunate circumstance, as this part of the Mediterranean is
particularly liable to sudden storms; and if it were not for sea-quoits,
and the still more popular game of dumps, which consists in
throwing small flat balls with lead inside on to a white-painted
square board, on which numerals from one to ten are inscribed, it
would be rather hard work to get through the weary hours. At
Naples an agent came on board with the London morning papers
four days old, which sold readily at half a franc each, and the
perusal of them has helped to kill an idle time, and, besides,
afforded topics for general conversation. For pedestrian exercise the
Orizaba is admirably adapted, as eleven times round the promenade
deck is supposed to be a mile, and at certain hours every one is
supposed to be doing his or her ‘constitutional;’ thus, what used to
be considered one of the bad effects of life at sea, its confinement,
is entirely got rid of. Captain Conlan, our commander-in-chief, when
off duty, has a friendly word for us all; but I must say, if tobacco be
a slow poison, some of us are in a bad way, for I think without
exception all the male passengers smoke; and at Gibraltar, where
tobacco and cigars are cheap, most of them replenished their
exhausted stores.
The principal event after leaving the Straits of Messina is the
appearance of Crete, by the side of which, with her snowy-capped
mountains, we steamed for about five hours. From her rocky
foreground, resting on the blue waves, rise three mountain ridges,
the chief of which ‘is many-founted Ida,’ towering 8,000 feet above
the sea. As a caution to travellers, let me assure them how much
one of Smith’s dictionaries would be appreciated. Smith, it may be,
is correct, but he is pedantic. Lemprière would, perhaps, be better;
in the home of legendary lore it is not wise to be over-critical. The
Orient Company publishes a guide-book, but it is of little practical
use, though it contains an immense amount of information, some
excellent maps, and is a marvel of cheapness. You rarely get in such
books what you really want to know. We have a professor on board,
but professors nowadays are somewhat common. Men who shave
and cut corns—men who examine your head, who risk their necks in
parachutes, who excel in gymnastics, are called, or call themselves,
professors; and I, perhaps because I know no better—probably it is
so—may be a little sceptical as to the class. I always think of Barry
Cornwall’s lines in which he speaks of

Professors of hall and college,


With a great deal of learning and little knowledge.

And, alas! I have known many such. It amuses me more to talk to


some of the third-class passengers. ‘Ah, sir,’ said one of them to me,
as we steamed out of Naples Bay—‘ah, sir, that is a very wicked city;
it allus reminds me of Nineveh.’ I was compelled to admit that I did
not know much of the wickedness of either; but that I did happen to
know that, excluding Jack the Ripper, there were not a few wicked
people left in London. I always like to look at home before I begin
censuring other people. There is a good deal of truth in the remark
of the old Californian, when Sir Charles Dilke told him ‘Californians in
the Empire City were called the scum of the earth.’ ‘Them New
Yorkers,’ was the old man’s reply, ‘is a sight too fond of looking after
other people’s morals.’
Just as we are nearing the lowlands of Africa, and Port Said—a
wretched place, where we stop a few hours to coal—is in sight, a
death occurs on board; a tiny babe, weary of the world of which it
knows so little, refuses to live any longer. In the drawing-room few
of us know of the event, and the gaiety goes on much as usual. I
rush on to the deck, and see a dark cloud of passengers at one end,
and there is the Bishop standing at a red kind of box or reading-
desk, repeating that grand burial service which is nowhere more
impressive than when heard in the ocean’s solitude, with nothing but
the wide, wide sea below, and the clear, moonlight sky above. The
parents are, of course, there to mourn, and the bearing of the little
crowd is sympathetic. The poor little corpse, covered by the British
flag, is placed on an inclined board, which is tipped over when the
sentence ‘we commit this body to the deep’ is reached, and the sea
receives its dead. I had only asked the doctor that morning what
was the state of health on board the ship, and his reply was that it
was as well as could be. Perhaps steerage passengers don’t count,
especially when babies. At any rate, the funeral is over, and we are
taking our evening tea as if nothing of consequence had occurred—
as if no tender mother’s heart had been torn with anguish as she
saw her babe fall a victim to the Reaper whose name is Death. Not
for a moment did the ship slacken her career, and we press on to
Port Said with all our might.
CHAPTER II.
EGYPT TO COLOMBO.

Coaling in Port Said—The Suez Canal—England the Main Support


—Donkey-drivers—The Electric Light—Ismailia—Suez—Aden—The
Red Sea.
Under a vermilion sky, as the sun sinks down into the west, we
approach the land of Egypt—a barren land, kindly to neither man nor
beast, fruitful only in sand, and hospitable only to the camel, who
seems here to be a friend in need, patiently following his turbaned
leader over the pathless desert. We have a little sand near
Southport, we have more still on the Lincolnshire coast at Skegness,
we have most of all on the Dutch coast, from Flushing to
Scheveningen, that gay resort of the Dutchmen and the Germans;
but they fail to give you an idea of the dreary and boundless waste
of sand through which that wonderful old man, M. de Lesseps, cut
his grand canal, which ought to have been done by Englishmen, and
which perhaps would have been, had not Lord Palmerston declared
in season and out of season that it could not be done, and that if it
were done it could never pay. When we stopped at Port Said,
looking as if only artificially raised out of the sea, I landed: partly to
say I had planted the sole of my foot in Egypt—the land of the
Pharaohs, of Joseph and his brothers, of Antony and Cleopatra, of
Origen and Hypatia and early Christian hermits, of grand
philosophies and theologies, which stir the pulses even of to-day—
and partly that I might have an evening stroll in a place not at one
time the safest for a white man to land, but which now is quite as
free from danger as any London neighbourhood—the happy hunting-
ground of the burglar and the thief. The fact was that at Port Said
we had to coal; and as we landed after dinner, it was a new
sensation to be rowed ashore by turbaned sailors, who were clothed
in what seemed to me in the twilight very much like petticoats. It
was rather risky, as the boat was crammed down to the water’s
edge. Nor was I much reassured as, after running up against the
ropes and being nearly capsized, the man at the prow called out in
broken English, ‘Never mind,’ to which I was obliged to reply that I
did mind, and that I ventured to hope he would take care of our
precious carcases. Apparently the advice was not thrown away, for
after a few minutes’ row, and after an attempt had been made to
collect the fare, which we all firmly resisted till on terra firma, we
landed where a couple of old women apparently, in reality sailors,
were standing with lanterns ready to receive us. As the fare was
only sixpence each way, I can’t say that the Egyptian watermen
were quite so exorbitant as some I wot of nearer home. There was
not much to see at Port Said; but it was better to be there than on
board ship while the process of coaling was going on. While at
dinner there was a sound all round as if a million of monkeys were
screaming and jabbering underneath. They were the coalheavers,
on board the big barges laden with coal that surrounded us on all
sides directly we had come to anchor. Each barge had two lights of
burning coals, by the glare of which we could see the porters in
strings of fifty at a time climbing up a ladder that led to the ship’s
inside, with coal-sacks on their shoulders, and streaming back again,
all the while screaming, as seems to be the manner of the Arab tribe
all the world over. They all scream. They screamed at us as we
stood on the deck; they screamed at us as they rowed us ashore;
they screamed at us as we walked the streets—or, rather, the one
long street which forms the town till it is lost in the sand of the
surrounding waste. On one side lies the market, and a mile or two
beyond is the old Arabian town. Men of all nationalities are well
represented in Port Said; but the Greeks have the best shops, where
a fine trade is done in cigarettes, photographs, and richly-worked
napkins, and helmets to keep off the sun in the Red Sea, and the
other products to be met with in Turkish bazaars. In the street it
was difficult to tell the men from the women, so weird and unearthly
seemed their make-up in the evening gloom. Two of the dark
bundles approaching me were, I concluded, women, as the faces
were concealed—all but the dark, round eyes, from the dangerous
glances of which, happily, my age protected me. The great
attraction of the place was a large café chantant, which, however, I
fancy, did duty as a gambling-house as well. On the bank, just as
you land, is a large building calling itself the Hotel Continental; but
as it was shut up, apparently it has not been a commercial success.
The houses, or, rather, the shops—for there were nothing but shops
to be seen—were all of wood and painted. On my return to the
ship, which was covered with coal-dust, I found we had an Egyptian
conjurer, who went through a performance such as we see any day
in England. But I must not say a word against a gentleman who
was so kind as to intimate that I was ‘a big masher.’
For a real Lotus-land, where it is always afternoon, commend me to
the Suez Canal. It is a busy spot. No spot is busier. Steamers,
especially English ones, are always passing up and down. It is an
expensive spot. You are fortunate if your steamer has not to pay a
thousand or two for the trip. The Orizaba has to pay £1,700 for
going through; but that does not concern you, if you have taken
your passage to Ismailia or Colombo, or one or other of the great
Australian ports. All that you have to do is to sit still and enjoy
yourself. There the good sailor and the bad one are equal. There
you fear no north or south simoom, no seas mountains high (I have
never yet seen them, and begin to believe in them only as I do in
stories of mermaids and mermen, or in legends of the sea-serpent
ever turning up at unexpected times and in unexpected quarters),
no rough blasts of the winter winds, no equinoctial gales. The
captain comes down from his bridge, the officers take it easy, and
you really need not to drive dull care away. On that calm water,
under that bright sky, you have no thought of time. All around you
is still life—the boundless sands, the distant hills, the camels, and
the Arabs encamped far away. All is repose, in the heavens above,
as well as in the earth beneath. It is true the beggars here and
there on the banks are a nuisance, but where are they not, either in
the Old World or the New? For eighteen or twenty hours you are at
peace—to read the last novel, to flirt with the last fancy of the hour;
to dream, if you like, in the broad daylight of other days and other
times. The big ship moves, but so slowly that you can scarce tell
that you are moving at all. The stewards bring your meals as usual;
your sleep is undisturbed. There is your morning bath, your
accustomed cigar, your game of chess, or your rubber of whist. Ah,
you are much to be envied! The pity of it is that the trip is so soon
over; that the dream is soon dispelled; that the curtain so soon falls
on the scene; that you have to get back again to the cares, and
troubles, and struggles of real life.
In the matter of the Suez Canal, Englishmen are paying rather dearly
for their faith in Lord Palmerston. It is to the credit of M. de Lesseps
that he conceived the idea, got together the money, and carried it
out, and by that means, as a patriotic Frenchman, secured for
France an influence in Egypt which, not to put too fine a point on it,
has not worked for the advantage of either Egypt or ourselves. The
officials of the Canal are French, the official language is French, the
neat little stations, with their painted wooden houses, protected here
and there by a palm tree struggling for life, are pre-eminently
French. Fortunately, Lord Beaconsfield bought some shares for the
nation, which gives us a locus standi. But the Canal, you feel, ought
to have been designed by British engineers and paid for by British
gold. It is emphatically England that keeps it going. The stream of
steamers ever sailing up and down by day or by night are chiefly
English steamers built in British shipyards, sailed by British captains
and officers, and filled with British goods. It is true France
subsidizes her steamers to struggle with England in all parts of the
world. It is equally true that Germany does the same, but they
cannot beat the British merchant and shipowner, who will not yield
without a fierce struggle the supremacy it has taken them centuries
to build up and sustain, and if the Canal manages to pay a dividend,
it is because of the constant passage of British ships. As we were
steaming along the Canal in one of the finest steamers of the Orient
line, and of any line, we met a French steamer on her homeward
trip. Mounseer looked politely at our crowded deck—his own
seemed deserted, though they do tell me that the accommodation
on board the French ships is remarkably good, and then our
steerage commenced singing with heart and soul ‘Rule, Britannia.’
They ought not to have done it, I know. It was a breach of good
manners; but if anywhere we may be pardoned for singing ‘Rule,
Britannia,’ it is in the Suez Canal.
On leaving Port Said, in a few minutes you are in the Canal, which
has been here protected from the shifting sand by a breakwater a
mile and a half long. On Lake Menzaleh, to the westward, are to be
seen wonderful flights and flocks of birds, including pelicans and
flamingoes, to detect which, however, requires an uncommonly
strong glass. Ships are piloted on the block system, under the
control of the head official at Port Said, who telegraphs the
movements of each ship as it slowly makes its way. At each of the
stations, or ‘gares,’ there are signal-posts, and a ball above a flag
says ‘Go into the siding,’ while a flag above a ball says ‘Go into the
Canal.’ You see a good deal of the country, an utter, miserable
desert at first, but soon hidden by the sand-banks. As you get
nearer to Suez, wandering Arabs and droves of camels may be seen
making their way along the burning waste, under the burning sun.
All day and all night the heavens are wonderful. Now and then you
meet a ship, and there is not much room to spare; now and then
one is run aground, and it is often weary waiting, as it is inexpedient
to go on shore and take a donkey-ride, in compliance with the
request of the donkey-drivers, who seem to scent a stoppage from
afar, and come to the bank, clamouring vociferously all the while. As
you proceed you find the boys and girls on each side keeping you
company, in hopes of the copper the kind-hearted visitor may feel
inclined to throw them. It is needless to add that they are loosely
clad, and are brown and sunburnt to look at. By night the electric
light on the sandy bank has a singularly strange effect, which is
more particularly apparent as another ship approaches, making the
sand where it catches the light seem as if there were drifts of snow
all round. As you enter the lakes the waters widen, and the speed is
greater; the scenery is also a little more attractive. Away on your
right is the land of Goshen, and Ismailia clusters prettily around the
summer palace of the Khedive. Here you drop the passengers for
Cairo, who are increasing in number every year—that part of Egypt
becoming increasingly a winter resort, essential to the comfort and
well-being of those who do not care for English cold and fog and
rain. It is a wonderful change and a great relief for the asthmatic to
spend a winter in Egypt. It is a pity that more cannot do so, but,
alas! few of us can spare the time, and many of us have not the
cash, and so a man must live where his bread is buttered, though to
do so prolongs his pains at the same time that it shortens his life.
As you look at Ismailia it seems a charming spot; however, the
condition of the place is by no means sanitary, and danger lurks
there under those green trees, beside those still waters. It has,
however, been the scene of high life, as when the Canal was opened
in 1869, when the Empress Eugenie, the Crown Prince of Prussia
and the Empress of Austria took part in the ceremony. At a later
date there was also exciting work in Ismailia when it became the
basis of ‘our only general’s’ brilliant campaign. The Canal and lakes
were filled with transports and men-of-war, and to the town an army
of 20,000 men looked for supplies. It was from thence they
marched to fight the battle of Tel-el-Kebir, and to send poor Arabia
prisoner for life to Ceylon, where, perhaps, after all, he is better off
than he would have been had he stopped at home. His life would
have been sacrificed had he remained.
Little of life is to be seen anywhere, but a few men are engaged in
cutting away the sand, while camels bear it far away. They are ugly
beasts, and never seem happy. They are, however, docile, and kneel
down while the men fill the panniers with sand, when they rise up
and walk away; or we come to a ferry where they are waiting to
cross, and display the same patient, forbearing, half-starved look.
The Egyptian donkey seems to me a far livelier animal. Now and
then a dog displays itself on the bank, but he is rarely a favourable
specimen of his race. Small steamers and barges, occupied in
connection with the improvement of the canal, are also met, but the
crew take little note of the white man, who, however, after all, has
got such a hold on the land that it is questionable, whatever
statesmen say at Westminster, whether it can ever be removed. It
seems as if Egypt could never be let alone. True, it was a great
country once, but that was long ago.
Again, we leave the Timseh, or the Crocodile Lake, behind, and
make our way to the Bitter Lakes, through many miles of Canal. The
lakes, history tells us, are the remains of a dried-up arm of the sea,
where once flourished the ancient port of Arsinoe. Here we meet
the slight tides of the Red Sea—that awful sea, whose waters at
some seasons range to a temperature of a hundred. It was hot as
we entered Port Said, it is hotter as we leave the Canal at Suez—the
new port of which, with its modernized hotel, its rows of trees, and
its modern warehouses, looks pretty from the water. Old Suez, a
mile and a half from the new town, is visible long before we reach
the fort. It is almost a pity that the steamers do not stay here a day
or two. The old town is the most characteristic of old Egypt, and the
rail will run you up there in a few minutes. It was the centre of the
highway between Asia and Africa. All around is the desert, while
mountains famed in history for ages are to be seen from afar.
Egyptians tell me that Suez is preferable to Cairo as a health resort.
One gentleman whom I met with told me that he wintered there
every year. As we picked him up on my return, I was obliged to tell
him that he did not look so well as when he went ashore a few
months previously. In excuse he owned that he had suffered from a
severe attack of rheumatic fever. It may be that Suez had nothing
to do with that. Perhaps at Cairo they would have told me Suez was
not a good place to go to. The water, however, is good, as we took
a good many tons of it on board. It was well that we did so. At
Aden, our next stopping-place, we found there had been no rain for
nearly three years.
We stop a few hours at Suez, and early in the morning commence
steaming down the Gulf of Suez, ere we float proudly over the
waters of the Red Sea. At length it seems to me that we realize all
that the poets have sung and painters have drawn of the Bay of
Naples—unclouded skies and a sea of brilliant blue. All day long we
are in sight of a romantic coast crowned with towering mountains,
with diversified peaks that in the sun seem to glow with light and
heat. As we approach they are brown or white or red, and then,
behind, they seem dark and stern as they rise out of the sleeping
waters. On our left are the Arabian mountains—Mount Sinai among
them—more or less connected with the religion dear to all men of
Anglo-Saxon race and tongue; the religion that has made modern
history what it is—the religion which they tell us in the pulpit is yet
to reign supreme. At dark—and it soon gets very dark in these
regions, in spite of the grand stars which shine lustrously on us in a
way of which no untravelled Englishman can form any adequate idea
—we are on the Red Sea, having just passed the wreck of a steamer,
as if to remind us that even in these days of science there are
accidents arising from fogs and currents and hidden rocks and
shoals which it is hard for any human ingenuity to guard against.
Just now a good deal of interest attaches to the Red Sea. On our
right are Suakim and Massowah, though too far off to be visible.
Small as the Red Sea looks on the map, it is 1,200 miles long. Coral
reefs and islands are so numerous that navigation is difficult and
dangerous. The coast on either side seems deserted, and only now
and then a lighthouse is to be seen, or the black hull of some small
Arabian trader, with the well-known enormous sail from the yard-
arm. However, there are one or two ports of importance on either
side. The chief of all is Jeddah—with a population of 40,000—which
is the port of the Mecca pilgrims, and which beside is the chief
market for pearls and the black coffee and aromatic spices from
Araby the Blest. Not far off is Mocha, a name familiar to British ears,
though the place itself has fallen into decay.
So far as we have travelled the Red Sea has behaved uncommonly
well. On the last voyage the heat was so intense that three times
the ship had to be turned in order that the passengers might have a
breath of cool air. As it is, no one finds the heat overpowering, and
to me it yields the same amount of enjoyment one feels in a Turkish
bath after the sweating process has got into full swing. We have
little walking now except in the early morning, or after dark, and no
gymnastic exercise of any kind. The little ones have already lost
their rosy cheeks. Sunday is well observed; one way or another
there is a good deal of preaching going on. The bishop takes in
hand the first-class passengers, while in the evening volunteer
preachers look after the souls of the second class. There was a
special service also in the steerage in the afternoon, when the
singing was at any rate very hearty.
Of course we gaze with no little pleasure at the island of Perim,
standing in the deep water a few miles before we reach Aden. The
French would have had it, the story goes, had not the Governor of
Aden, who had his suspicions aroused as the French commander,
who was sent to plant there the French flag, sat drinking champagne
at his hospitable board, sent two notes, one to the harbour-master
ordering him to delay the coaling, and another to the commander of
a gunboat to sail at once with some artillerymen for Perim. Such is
the story as told by Sir Charles Dilke and other clever men; but the
real fact is that it had been long before taken possession of by the
old East India Company. At any rate, it is of no use to our French
neighbours, now that they have lost Egypt, and that the control of
the Canal has passed into English hands. Now the French have no
Eastern Question. How we must all envy them!
In a little while we are out of the Red Sea, which at this time of year
is really agreeable. All day long we have had a strong head wind,
which has rendered the sultry atmosphere quite cool and genial.
Provided an invalid is a good sailor, I should say, as far as we have
gone, it would be impossible for him to have a more agreeable trip,
or one more likely to return him to his native land of fog and frost
and rain a better man. Everyone tells me that I am looking
wonderfully better for my voyage. I am glad to hear it, as what is
sauce for the goose is sauce for the gander, and I write in the hope
that those who can afford it will follow in my steps. I have offered
myself as an experiment for the sake of my asthmatic and elderly
friends. So far as I have gone the experiment has succeeded
beyond my most sanguine expectations.
We made rather a long stay at Aden, where most of the party went
ashore; I did not, for of two evils a wise man chooses the least, and
it seemed to me a greater evil to be rowed ashore and landed on a
sunburnt rock where no water is than to fight with the coal-dust on
board and to listen to the perpetual chattering of the natives. We
have to be thankful that we are safe out of the Red Sea, which is
certainly, with its sunken coral reefs and ragged rocks rising straight
out of the water, as difficult a piece of navigation as any of which I
ever heard. A captain had need be careful. The sights of Aden are
few—a low building or two on the rocks, a native town a few miles
off (not worth seeing), and water-tanks more useful than
picturesque. Before we had anchored the Somali boys rowed round
us in their little cockleshell boats, ready to dive for any coin thrown
into the water. Then came the barges, black with coal, with long,
dark, lightly-dressed natives, to convey the desirable mineral on
board. Their woolly heads seem impervious to the sun’s rays, and if
they have dark skins, it but enhances the effect of their glistening
teeth. The costume I like best is that of the native policeman, which
consists of what looks to me like a nightgown, a turban, and a black
necklace. A couple of gentlemen come on board: they wear blue
jackets and rich-coloured silk skirts. Their hair is done up in a knot
behind, and is kept in good order in front by a tortoise-shell comb.
A few salesmen, with ostrich-feathers or wicker baskets, come to do
a little business, but overboard the battle rages all day long, as the
boys clamour for coins and imploringly stretch their skinny arms to
the upper deck. A coin is tossed into the water: in a second they
turn heels over head and disappear, in another second they have
found it and are ready for another. The boats which take the
passengers on shore are large, and manned by four or five men
dressed in blue cotton. The charge is a shilling each way. The
landing is easy enough, but in this hot climate I question whether a
visit repays the trouble. Most of the passengers, however, seem to
be of a contrary opinion; nor is that to be wondered at when I state
that many of them are ladies—or in other words, true daughters of
Eve. They drive out to the tanks, and come back with headache and
ears aching as well. In the meanwhile the row on board is
incessant, as the wild Arabs of the sea scream for coins and perform
all sorts of wonderful tricks in the way of diving. From the deck the
scene is interesting and animated. Aden, with its brown rocks, is on
our right: and ahead and on the other side of the bay runs the
yellow sand, terminating—as everything does, apparently, on this
rugged coast—in a peak of rocks. It is only the rock that belongs to
us, and what we see are the offices of the company and the
residence of the officials. The town is a terrible place to live in. On
your way to the old town you meet endless strings of camels with
the produce of the country, as in Aden itself not a blade of grass
grows. The harbour is alive with ships, and steam-tugs towing the
barges laden with coal, and native boats. Over the water seagulls
and a bigger bird, apparently a kind of hawk, fly ceaselessly in
search of their prey, and beneath sharks abound, as a white man
would soon find to his cost were he to attempt a swim. Apparently
the shark prefers the white man to the black, and there I and the
shark agree. Away from Aden, which looks charming in the warm
light of the setting sun, we pass out to the Indian Ocean, and the
transition is a relief, as we leave behind the perpetual jabber of the
natives of that fortunate district—I write fortunate advisedly, for the
English spend a mint of money there, and the natives, to their credit
be it written, know how to charge. In one particular case which
came under my knowledge £2 was asked for an article for which
ultimately the seller was content with 2s. We were to have had an
addition to our live cargo in the shape of a smart little lad, whom an
Australian had engaged to accompany him. The father was willing,
but the brother, a fine-looking darkey, objected, and the boy was
taken off again, apparently much against his will. I am told that
many of these lads are taken away—they are apprenticed to the
white man for a term of three years, the white employer agreeing to
pay £12 a year in the shape of wages. As boys, they seem as active
as monkeys. Whilst I was watching, one of them had his boat filled
with water. In a moment he was out, and, rocking the boat till it
was free from water, he paddled away with his one oar as if an upset
in the water was an everyday occurrence; and the men seemed as
agile as the boys—tall and muscular, with long arms and legs, and
without an ounce of spare flesh. I fear by the side of them our
Thames watermen would have but a poor chance.
Our captain tells me he can take a holiday now for the next few
days. Out on the broad expanse of the Indian Ocean we are away
from sunken rocks and coral reefs. According to Mr. Froude, when
he made his way to Australia, he seems to have got through a good
deal of Greek and Latin. In this delicious climate study of any kind
seems quite out of place; but the sea air makes one hungry and
indolent. We live well, and we have a library, which yields me a
novel a day—of course I skip the descriptive parts and the
sentimental—and as we rush over the blue sea, a cooling breeze
meets us, and it is enough to live. I feel as if I were Ulysses and
Christopher Columbus and Captain Cook rolled into one. We see no
land, no ships, no birds in the heavens above, no fish in the water
beneath. Night comes with its clear stars and its dark waves, and
our pace is still the same. It is very wonderful, and none the less so
that it is a wonder of everyday occurrence. Over the ship, in all
parts, we have a perfect blaze of light—nine miles of electric wire!
and outside all is darkness and mystery—a darkness and a mystery
man has learned to master. Science has done that much for him.
Will science unveil the darkness and mystery of being in a similar
manner? I fear not. Happily there is a Judge

Who ends the strife


Where wit and reason fail.
CHAPTER III.
COLOMBO TO ALBANY.

Prosperity of Colombo—Native Extortioners—Buddhist Temple—


Life in the Streets—On the Indian Ocean—Stormy Seas guard
Australia—English Coolness—Western Australia.
A scene of Oriental loveliness opens on my dazzled eyes this
morning. On my right is a fine breakwater, with a lighthouse at the
end, which altogether cost £650,000, and the building of which
occupied ten years. In front of me is the port of Colombo, filled with
shipping from every quarter of the world. On my left is a long row
of cocoa-palms, looking refreshing and green after the weary waste
of waters we have travelled over. As I write the catamarans of
Ceylon begin to crowd around. They are long, narrow boats—a
stout Englishman would find it hard to sit in one of them—rowed by
dusky sailors, with long oars, many of which seem to terminate in a
sort of spade. The men are naked, with the exception of a cloth
round the loins, and are apparently strong and sinewy. A few feet
off is the outrigger, so formed that the boat never upsets. They may
be useful, these boats, but have an awkward appearance to an
English eye. They bring on board the men who have come to fetch
the washing for the passengers, which will all be finished and on
board before we leave. Then come the tailors, who will measure
you for a suit of white, which will also be finished ere we depart.
Then come the barges with the coal, and I get into a tug and go on
shore. We all do it, for the Orizaba is unbearable while the coal is
being put on board.
It is strange to remember that at one time Colombo was so far off,
that the news of her Majesty’s accession to the crown, which
occurred on June 20, 1833, did not reach Colombo till some
immense time after. Ceylon was between ninety and a hundred days
from England, now it is only eighteen. Long after Lieutenant
Waghorn had opened up the overland route, her Majesty’s
Government with characteristic stupidity still continued to send the
mails by the Cape of Good Hope. It was left to the opening of the
Suez Canal to render Ceylon easy of access, and to render it possible
for English men and women to live there with comfort and luxury, in
my humble opinion, far superior to anything we have at home, and
Ceylon is redolent of prosperity, whether we regard its population, its
revenue, or its trade. Directly the traveller lands at Colombo he feels
as if in an enchanted isle.
As soon as you land in Colombo you are in India, and in, perhaps, its
most attractive part. There are some 130,000 people in the city, all
mild and gentle, and well-behaved. At once you are attracted by the
grand Oriental Hotel, which faces the port; you pass on a few steps,
and come to lofty shops, filled with all the dazzling products of the
East, with gardens in the rear, and it is hard to avoid being taken in,
for the swarthy shopkeepers are clamorous, and, in the matter of
cheating, quite the equal of the Heathen Chinee. A friend of mine
purchases a white sapphire, as it is called, for eighteenpence, for
which the owner asked four pounds, and I much fear my friend has
been victimized after all. An unfortunate gentleman shows me a
gold ring for which more than three pounds was paid, and which
turns out not to be worth a halfpenny. But it is too hot to walk and I
hire a carriage, and, with a companion, take a ride of a couple of
hours for the small charge of three shillings. We start for the
Buddhist temple, a whitewashed building about a couple of miles
off. Externally there is little to see. It stands in a green court,
surrounded by white walls, and the schoolmaster, after we have
dropped a shilling into the box, and given him a trifle for himself,
takes us round. The place consists of three courts, but the light is
bad, and the schoolmaster’s English very defective, and I came back
little wiser than when I entered. The things that principally
impressed me were a recumbent gigantic image of Buddha, a court
in which there were seventy-five painted images of Buddha, and a
smaller one in alabaster, and a long wall covered with
representations of Buddhist legends which the schoolmaster, alas!
did not condescend to explain. The Buddhist temple is small, and
the only sign of its being used are the flowers scattered before the
images, the offerings of his followers. The Christians, at any rate,
make a good show as far as buildings are concerned, the Church of
England heading the list with Christ Church Cathedral and nine other
churches. The Presbyterians have two, the Wesleyans six, the
Baptists one, the handsomest place of worship in the town, to say
nothing of the Salvation Army, which has also a station here. Some
people argue that Buddhism is such an exalted form of worship that
we ought not to interfere with the faith of the people. That,
however, is not the feeling of the whites in Ceylon, who know
Buddhism best. To myself, with all my sympathy for Buddhism, the
Buddhist temple seemed a very poor affair. I should have said there
are also many Mohammedans, and their mosques are numerous.
The streets are an endless delight, as you pass ladies riding in little
hooded chairs on wheels, drawn by men; or swells, native or
English, in broughams with latticed sides, so as to admit the breeze;
and cars, rather rickety, drawn by native ponies and driven by native
drivers, whom you may trust to take you to all the objects of interest
to be seen, such as the hotels, the gardens, the museum, etc. Then
there are native waggons, thatched with dried leaves, and drawn by
little dun-coloured bulls with humps on their backs—active animals,
which trot along with a swiftness of which a Sussex farmer, who still
ploughs with oxen as his fathers before him, can have no idea.
Under the trees you see the natives sitting over their dirty rice,
which they still eat with unwashed hands. Where the natives live
the population is almost as dense as in the East-end of London; and
as to the pickaninnies, they are everywhere, with their little curly
heads, sparkling eyes, and half-naked bodies, their mothers, in
coloured dresses, leaving them pretty much to take care of
themselves. Boys and girls run after us all the way with flowers, or
bright beetles, or packets of cinnamon and other woods. All is
strange, and all is attractive—the gorgeous butterflies that flit in the
sun, the crowded streets, the native dwellings, with a screen of lath,
which apparently does duty for a door; the tempting bungalows,
standing in the midst of gardens with Oriental flowers, or under the
shade of palm-trees, of which we in England can only dream; the
grand promenades, where the residents walk of an evening to catch
the refreshing sea-breeze; and the handsome parks, where English
bands play English airs to the delighted crowds. The town is
prosperous, undoubtedly. There are fine English barracks, and
England’s martial sons are to be met with everywhere. The whole
island prospers under English rule. Ceylon’s staple products—tea,
coffee, and cinchona—employ hundreds of men, women, and
children of different classes, and now an attempt is being made to
introduce fish-curing. I could almost envy Arabi his place of
banishment. I felt inclined to say with the poet, if there be an
Elysium on earth, it is this; but then I was there in the cool time of
year, when life is enjoyable, and when even the white man has a
little of his native colour left. Yet even enchanting Colombo (I did
not realize Heber’s Ceylon’s spicy breezes, quite the reverse, but
perhaps that was my misfortune rather than my fault) has its
drawbacks. As I am standing opposite the hotel, a native
approaches with a small basket. He puts the basket on the ground
and begins to pipe. To my horror, as he does so, a hooded cobra,
lying perdu, with its black eyes and silver hood, erects itself on its
tail as if ready to dart on its prey. Now, as above all things I hate
snakes, and cobras most of all, I fled the spot and at once made for
the tug, leaving the native juggler, I doubt not, not a little
astonished at my want of taste.
Life on the ocean wave is really to be enjoyed on the Indian Ocean—
an immense water, pleasanter to look at and sail on than the
Atlantic, of which no one is sure, and which is variable as woman
herself. It is impossible to overrate the beauty of the azure waves
and skies which greet us every day. Nevertheless, we may have too
much of a good thing, and no one regrets that we are approaching
the end of our journey. At church on Sunday it seemed to me that
we are much given to the use of misleading language. It was
announced that the bishop would hold divine service, and perhaps
he did so; at any rate, the assembly was numerous, and in
appearance devout; but I missed the firemen who kept up the
steam, the men on the outlook, the steersman on the bridge, and
the inmates of the room set apart for the due study of charts. Were
they not engaged in a service equally divine?
How, one by one, vanish the illusions of youth! Yesterday I would
have sworn mangoes were delicious eating, for I have read so a
thousand times; but to-day I have discovered the much-talked-of
mango to be an impostor, in shape like a potato, with a great stone
inside, only to be thrown away. Then what raptures we hear about
the Southern Cross! I have seen it and it charms no longer, and the
beauty of it is that the Australians who most rejoice in it seem
utterly unable to tell you in what part of the heavens it shines. Then
take the tropics. What descriptions one reads of tropical heats:
heats fraught with deadly fever—heats so intense that an old man
may well shrink from the danger of encountering them! I have been
now nearly a week in the tropics, and they are really delightful. It is
true you are warm; it is true that when the ports are closed by night
the atmosphere in the cabin is apt to be unpleasant—but then that is
of rare occurrence—and the tropics, I hold, so far from deserving to
be run down, are favourably to be compared with London fogs and
cold. We have now crossed the line, and have sailed for days along
the Indian Ocean. Not a drop of rain has fallen on the deck, not a
touch of bronchitis is to be met with in anyone aboard, not a ripple
is to be seen on the great blue plain of the sea save that made by
the Orizaba as she ploughs her majestic way at the rate of 320 miles
a day. I should say, as far as my experience goes, any elderly man
or woman, who in London suffers from its uncertain climate, would
find the atmosphere of the Indian Ocean an immense change for the
better. If any such require a real sanatorium, I would
conscientiously recommend them a trip to Australia and back, if they
can stand the sea, and if they have the good luck to secure a berth
in such a ship as the Orizaba. By all means let them have a chair; I
did not take one, as I thought it would not be worth the trouble, and
even at Naples, when an ex-M.P. who went ashore there kindly
offered me his chair as a parting gift, I had not sense enough to
avail myself of the offer; but I have regretted it ever since. People
who have chairs put them in the best places, where the breeze is
most grateful, and thus enjoy a great advantage over those who can
do nothing of the kind. By all means also let the tourist have a
white dress; it is the only kind of dress to be tolerated on the Indian
Ocean, and, of course, he must have canvas shoes, which he will
find the more useful if they are soled with indiarubber rather than
leather. You are bound to take as much exercise as you can, and it
is not pleasant to fall on a slippery deck.
Let the intending traveller choose, if he can, his time. Between
November and March the ocean is delightful. If, however, it is
entered between May and September, when the thick weather and
fierce winds of the south-west monsoon prevail, it is very much the
reverse. It is a run of more than 3,000 miles from Colombo to Cape
Leeuwin, the south-west point of Australia, and this is the most
monotonous part of the journey, as there is nothing to be seen on
the sea. We only met two ships after leaving Colombo, and people
grow sleepy and dull, and the conversation, at no time brilliant,
rather flags. One can scarcely imagine what the horror of the
passage was in not very remote times. When the bishop first went,
he tells me, it was in a sailing vessel, and they were three months
on the voyage, revelling on salt pork and beef all the while. Our
modern bishops don’t care much for that sort of diet, nor, if I may
judge by the way we live, their flocks either, and this, by the way, is
the real difficulty and danger on ship-board. As a rule, people are ill
because they eat and drink too much. I have been a teetotaler all
the while and have tried to eat as little as I could, and hence I am at
any rate as well as anyone aboard. Again, let me caution the
traveller to avoid a ship that rolls. In this respect we are wonderfully
fortunate. The Orizaba never rolls, and in the worst weather we
dine in comfort, no crockery is smashed, and no steward spills a
drop of soup. In the dark watches of the night it is the rolling that
keeps passengers wide awake, and if ships can be built like ours it is
a shame to send people on such long voyages in any others. In the
tropics the clouds that come up as the fiery sun sinks into the blue
sea are awful, darker and more threatening than any I have seen
elsewhere. Then they disappear, and then again reappear, to fly
with the early dawn. It is a long time before one can be reconciled
to their grandeur. I am not surprised that people feel timid. There
is a good deal to make people nervous at sea. A lady passenger
tells me that when she goes to bed in rough weather, every night
she expects to go to the bottom. I gave her what comfort I could;
but then, as Festus grandly tells us, we live by heart-throbs not by
years, and so the poor woman is to be pitied after all.
Not in summer calm, not when the gentleness of heaven is on the
sea, do we approach the Australian coast. The garden of the
Hesperides was guarded by dragons; and approach the Australian
continent, for such it really is, which way you will, you find her
defended by winds that are ever howling and seas that never are at
rest. They did their best to frighten us as we made for the point
where first we greet the granite rocks of the Land of the Golden
Fleece; of course, there is no danger, and everyone pretends to
enjoy it. As to myself, I frankly own—in spite of Byron and dear old
Captain Basil Hall, whose pictures of sea-life, when I was in jackets,
made everyone long to be a sailor—that I prefer calm to storm, and
that never do I love the ocean so much as when it has ceased to
roar. There are people who feel otherwise, just as there are people
who enjoy the bagpipes, but they are the exception rather than the
rule. It may be that the danger is little, but the motion of any ship
on a stormy sea is unpleasant. It is to be questioned, however,
whether there is any other sea-voyage so long, and at the same time
attended with so little inconvenience, as this Australian trip, and I
can quite understand how ready the Australians are to run ‘home,’ as
they call it. They love Old England to the very bottom of their
hearts. Some of them are quite ready to return and leave their
bones amongst us. But we drive them away. One of my
companions, for instance, has been spending a few weeks in
London. He is a lawyer, and has made a lot of money, gotten chiefly
at Ballarat in the good old times, when, instead of the ordinary six-
and-eight, he always pocketed a fiver. It was his intention to have
bought an estate and settled in England; but then it occurred to him
that if he did no one would ever come to see him—at any rate, such
was the universal testimony of those of his friends who had settled
down in the old country, one of them a gentleman who had done the
State some service and who had been presented at Court; and so
my friend returns to Australia—swearing he will never go to London
again—where he seems to have spent his money like a Nabob.
Another complaint which I hear in many quarters is that Englishmen
are ungrateful. One gentleman tells me how he had exerted himself
on behalf of a young lad who had come out to Melbourne friendless,
did all he could for him, treated him, in fact, as his own son, even
had a gushing letter of thanks and gratitude from the mother, and
yet when he called upon her in London she did not take the slightest
notice of him; and in another case, where he introduced himself to
the father of two young men to whom he had been the means of
rendering much assistance, and to whom he had extended the
utmost hospitality, all he received was a formal invitation to call
when that way, and that only after he had met the grateful parent
twice in the streets of the county town near which he lived.
Colonials who have been hospitable to English visitors naturally
expect a return of hospitality when they find themselves strangers in
a strange land; and Englishmen should remember that it is at all
times a duty to perpetuate the traditions of old English hospitality,
and to take in the stranger in the Scriptural rather than in the
modern way.
At length I have seen an albatross, and that may be taken as an
indication that we are getting near our journey’s end. It is a large
bird, as big almost as a turkey, with white body and dark wings, but
not often to be seen at this season of the year. For awhile we
skirted the Australian coast, and dropped some thirty passengers for
Western Australia at Albany, its chief port. They were sent ashore in
a tug in rather a primitive fashion, and we had plenty of time to
admire the magnificent harbour surrounded by granite rocks,
enclosing a wide expanse of water, which we enter between two
rocks, on one of which is a lighthouse. Of human habitations we
saw nothing save one or two on the brow of a hill, at the bottom of
which has been built a long railway pier, which railway, as it is not
complete, is only used once a week, when the steamers arrive, for
the purpose of conveying mails and passengers to Perth. ‘I suppose
the first port you touched at was Perth?’ said an English M.P. and
distinguished educationalist to me. Alas! it would have been hard
work to have taken the Orizaba to Perth. Perth is the capital of a
country eight times as large as the United Kingdom, which is at
present a Crown colony, but which is to be made directly the home
of a self-governing community. We dropped at Albany a young man
who has been sheep-farming there for fifteen years, and is quite
satisfied with the result. You could hardly credit how many
thousand acres he has hired of the Government at a rental of 10s. a
thousand acres. He has no white neighbours, and his labourers are
chiefly native blacks, with whom, he tells me, he gets on very well.
The country, he says, is well fitted for agricultural purposes, and
there is plenty of good land to be bought at 10s. an acre. Hitherto
the difficulty has been how to dispose of the produce, but that will
shortly cease, as the district is now being opened up by railways,
and from all that I can hear it is just the country for the British
farmer who feels inclined to clear off before he has lost his last
farthing in the vain attempt to compete with the foreign producer.
In Western Australia, with a little capital, he may certainly do well.
Everyone says Western Australia is the country of the future. As to
Albany itself, it is growing rapidly, and has a population now of about
2,000. It seems to me prettily situated, and already people who
have made a little money have fixed upon it as their residence.
There are Church of England, Wesleyan, and Presbyterian churches
there, and it boasts a paper—published weekly for threepence, and
dear at the money—which found a large sale on board, for the sake
mainly of its meagre telegraphic intelligence relating to English and
European affairs. After the dreary monotony of the sea it was
pleasant to look on the hills which hid Albany and its surrounding
district from the vulgar gaze. On one hill there was a long trail of
smoke, which indicated that somewhere there was a large bush fire;
and climbing up the sides of all was a scanty undergrowth, which if
good for neither man nor beast, had an appearance of verdure,
which, to the eye, seemed a living green, now and then varied by
stretches of yellow or white sand; and behind, though not visible to
us from the deck of the steamer, stretched a forest, full of a black
wood which makes the finest railway-sleepers in the world. On the
whole, it may be said Western Australia is bound to go ahead.
CHAPTER IV.
IN THE COLONY OF VICTORIA.

Melbourne Gleanings—Dr. Bevan—Night at a Bungalow—Cole’s


Book-shop—A Day at Sorrento—White Cruelty to the Aborigines—
Coffee Palaces—Dr. Strong—The Presbyterian Church in Collins
Street—The Late Peter Lalor—Ballarat—Romance of Gold Mining
—Sydney and Melbourne compared—Australian Rogues—
Suburban Melbourne—Victorian M.P.’s—Victorian Politics.
The stranger who makes his first trip to Australia is not a little
astonished by the extreme cold which greets him as he nears his
destination. You hear so much of Australian heat that you are not a
little astonished to find the nearer you get to your journey’s end the
colder it becomes. In the tropics we had all given up warm clothing,
but as we reached Western Australia great-coats by day and
blankets by night came into fashion. People were wrapped up as if
we were on the coast of England rather than of Australia, and as to
sleeping with the ports open, that was quite out of the question.
This is an admirable provision of Nature. It gives us the advantage
of having the body braced up before it encounters the formidable
heat which, according to all accounts, awaits us on shore. Another
thing that strikes a stranger, as he studies the papers from all parts
of the country, is the extraordinary difference in the weather as
recorded in different localities. For instance, I find at Sydney the
weather is described as delightfully cool, while at Adelaide on the
same day it is recorded as the hottest of the season. In one district
I read how the rain has come down in a perfect deluge, whilst in
another men and vegetables are dying from the want of water. At a
town in Queensland, the heat is so intense that many are dying daily
of sunstrokes, and the insurance agents have been telegraphed to
not to effect any more insurances, whilst in another locality I read of
a heavy fall of snow. The fact is, it is impossible to realize the size
of the Australian continent, twenty-six times larger than Great Britain
and Ireland, or the various kinds of weather to be met with, till you
are on the continent itself.
A pleasant trip of a day and a half from Adelaide, most of which time
was passed in sight of land, enabled us to reach Melbourne—
marvellous Melbourne, as it has been called—in time to go on board
the Lusitania and bid good-bye to Miss von Finkelstein, who is, she
tells me, wonderfully delighted with her Australian trip, and intends
returning again. She goes now as far as Port Said, and thence she
makes her way to Jerusalem. I then get into the train, and after a
run of half an hour along a flat district, partly waste and partly built
over with little wooden villas—prettily painted, each with its tiny
garden, which seemed to me to have a wonderful knack of getting
burnt down every night—find myself landed in the noble
thoroughfare, which seems to me to run from one end of the city to
the other, known as Collins Street; and almost the first person I
meet—at any rate, the first one I recognise—is Dr. Hannay, who is
leaving by the next mail steamer, and who is looking very well,
though he tells me he has been much tried by the great heat of the
last fortnight. The dust and the sun are trying, and I get back to the
ship for dinner.
When next I go on shore it is Sunday morning, and a grateful breeze
awaits me as I make my way along picturesque and stately Collins
Street—a street which would be an ornament to London itself. The
public-houses are closed, the tramcars have ceased running, and the
busy crowds that block up the footways on the week-day are away.
Instead of them there are the church-goers—well-dressed, sedate,
orderly—just as we may see anywhere in England on the Sabbath.
And if I miss the sound of the church-going bell, I know not that
that is an unmitigated loss—indeed, as far as London is concerned in
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like