Skip to content

Commit 47d3d8c

Browse files
committed
Improve method and variable names on quickstart pages (en)
Replace single character names with more descriptive ones.
1 parent d9562fa commit 47d3d8c

File tree

2 files changed

+34
-35
lines changed

2 files changed

+34
-35
lines changed

en/documentation/quickstart/2/index.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ What if we want to say “Hello” a lot without getting our fingers all
2121
tired? We need to define a method!
2222

2323
{% highlight irb %}
24-
irb(main):010:0> def h
24+
irb(main):010:0> def hi
2525
irb(main):011:1> puts "Hello World!"
2626
irb(main):012:1> end
27-
=> :h
27+
=> :hi
2828
{% endhighlight %}
2929

30-
The code `def h` starts the definition of the method. It tells Ruby that
31-
we’re defining a method, that its name is `h`. The next line is the body
30+
The code `def hi` starts the definition of the method. It tells Ruby that
31+
we’re defining a method, that its name is `hi`. The next line is the body
3232
of the method, the same line we saw earlier: `puts "Hello World"`.
3333
Finally, the last line `end` tells Ruby we’re done defining the method.
34-
Ruby’s response `=> :h` tells us that it knows we’re done defining the
34+
Ruby’s response `=> :hi` tells us that it knows we’re done defining the
3535
method. This response could be `=> nil` for Ruby 2.0 and earlier versions.
3636
But, it's not important here, so let's go on.
3737

@@ -40,10 +40,10 @@ But, it's not important here, so let's go on.
4040
Now let’s try running that method a few times:
4141

4242
{% highlight irb %}
43-
irb(main):013:0> h
43+
irb(main):013:0> hi
4444
Hello World!
4545
=> nil
46-
irb(main):014:0> h()
46+
irb(main):014:0> hi()
4747
Hello World!
4848
=> nil
4949
{% endhighlight %}
@@ -54,14 +54,14 @@ that’s all you need. You can add empty parentheses if you’d like, but
5454
they’re not needed.
5555

5656
What if we want to say hello to one person, and not the whole world?
57-
Just redefine `h` to take a name as a parameter.
57+
Just redefine `hi` to take a name as a parameter.
5858

5959
{% highlight irb %}
60-
irb(main):015:0> def h(name)
60+
irb(main):015:0> def hi(name)
6161
irb(main):016:1> puts "Hello #{name}!"
6262
irb(main):017:1> end
63-
=> :h
64-
irb(main):018:0> h("Matz")
63+
=> :hi
64+
irb(main):018:0> hi("Matz")
6565
Hello Matz!
6666
=> nil
6767
{% endhighlight %}
@@ -77,14 +77,14 @@ point. You can also use this to make sure that someone’s name is
7777
properly capitalized:
7878

7979
{% highlight irb %}
80-
irb(main):019:0> def h(name = "World")
80+
irb(main):019:0> def hi(name = "World")
8181
irb(main):020:1> puts "Hello #{name.capitalize}!"
8282
irb(main):021:1> end
83-
=> :h
84-
irb(main):022:0> h "chris"
83+
=> :hi
84+
irb(main):022:0> hi "chris"
8585
Hello Chris!
8686
=> nil
87-
irb(main):023:0> h
87+
irb(main):023:0> hi
8888
Hello World!
8989
=> nil
9090
{% endhighlight %}
@@ -121,6 +121,6 @@ and a bunch of methods for that class. Also notice `@name`. This is an
121121
instance variable, and is available to all the methods of the class. As
122122
you can see it’s used by `say_hi` and `say_bye`.
123123

124-
So how do we get this Greeter class set in motion? [Create an
125-
object.](../3/)
124+
So how do we get this Greeter class set in motion?
125+
[Create an object.](../3/)
126126

en/documentation/quickstart/3/index.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ header: |
2020
Now let’s create a greeter object and use it:
2121

2222
{% highlight irb %}
23-
irb(main):035:0> g = Greeter.new("Pat")
23+
irb(main):035:0> greeter = Greeter.new("Pat")
2424
=> #<Greeter:0x16cac @name="Pat">
25-
irb(main):036:0> g.say_hi
25+
irb(main):036:0> greeter.say_hi
2626
Hi Pat!
2727
=> nil
28-
irb(main):037:0> g.say_bye
28+
irb(main):037:0> greeter.say_bye
2929
Bye Pat, come back soon.
3030
=> nil
3131
{% endhighlight %}
3232

33-
Once the `g` object is created, it remembers that the name is Pat. Hmm,
33+
Once the `greeter` object is created, it remembers that the name is Pat. Hmm,
3434
what if we want to get at the name directly?
3535

3636
{% highlight irb %}
37-
irb(main):038:0> g.@name
37+
irb(main):038:0> greeter.@name
3838
SyntaxError: compile error
3939
(irb):52: syntax error
4040
from (irb):52
@@ -81,11 +81,11 @@ Ah, that’s more like it. So let’s see which methods our greeter object
8181
responds to:
8282

8383
{% highlight irb %}
84-
irb(main):041:0> g.respond_to?("name")
84+
irb(main):041:0> greeter.respond_to?("name")
8585
=> false
86-
irb(main):042:0> g.respond_to?("say_hi")
86+
irb(main):042:0> greeter.respond_to?("say_hi")
8787
=> true
88-
irb(main):043:0> g.respond_to?("to_s")
88+
irb(main):043:0> greeter.respond_to?("to_s")
8989
=> true
9090
{% endhighlight %}
9191

@@ -111,22 +111,22 @@ objects of that class. So, let’s create a new object and play with its
111111
`@name` property.
112112

113113
{% highlight irb %}
114-
irb(main):047:0> g = Greeter.new("Andy")
114+
irb(main):047:0> greeter = Greeter.new("Andy")
115115
=> #<Greeter:0x3c9b0 @name="Andy">
116-
irb(main):048:0> g.respond_to?("name")
116+
irb(main):048:0> greeter.respond_to?("name")
117117
=> true
118-
irb(main):049:0> g.respond_to?("name=")
118+
irb(main):049:0> greeter.respond_to?("name=")
119119
=> true
120-
irb(main):050:0> g.say_hi
120+
irb(main):050:0> greeter.say_hi
121121
Hi Andy!
122122
=> nil
123-
irb(main):051:0> g.name="Betty"
123+
irb(main):051:0> greeter.name="Betty"
124124
=> "Betty"
125-
irb(main):052:0> g
125+
irb(main):052:0> greeter
126126
=> #<Greeter:0x3c9b0 @name="Betty">
127-
irb(main):053:0> g.name
127+
irb(main):053:0> greeter.name
128128
=> "Betty"
129-
irb(main):054:0> g.say_hi
129+
irb(main):054:0> greeter.say_hi
130130
Hi Betty!
131131
=> nil
132132
{% endhighlight %}
@@ -181,7 +181,6 @@ class MegaGreeter
181181
puts "Goodbye #{@names}. Come back soon!"
182182
end
183183
end
184-
185184
end
186185

187186

@@ -197,7 +196,7 @@ if __FILE__ == $0
197196

198197
# Change the name to an array of names
199198
mg.names = ["Albert", "Brenda", "Charles",
200-
"Dave", "Engelbert"]
199+
"Dave", "Engelbert"]
201200
mg.say_hi
202201
mg.say_bye
203202

0 commit comments

Comments
 (0)