Merge pull request #1597 from pzula/ruby-more-strings

[ruby/en] Adds more string operations to ruby doc
This commit is contained in:
Adam Bard 2015-10-18 11:57:53 +08:00
commit c64ec7afe9

View File

@ -12,7 +12,8 @@ contributors:
- ["Dzianis Dashkevich", "https://github.com/dskecse"]
- ["Levi Bostian", "https://github.com/levibostian"]
- ["Rahil Momin", "https://github.com/iamrahil"]
- ["Gabriel Halley", https://github.com/ghalley"]
- ["Gabriel Halley", "https://github.com/ghalley"]
- ["Persa Zula", "http://persazula.com"]
---
```ruby
@ -107,6 +108,12 @@ placeholder = 'use string interpolation'
'hello ' + 3 #=> TypeError: can't convert Fixnum into String
'hello ' + 3.to_s #=> "hello 3"
# Combine strings and operators
'hello ' * 3 #=> "hello hello hello "
# Append to string
'hello' << ' world' #=> "hello world"
# print to the output with a newline at the end
puts "I'm printing!"
#=> I'm printing!
@ -284,7 +291,7 @@ end
#=> iteration 4
#=> iteration 5
# There are a bunch of other helpful looping functions in Ruby,
# There are a bunch of other helpful looping functions in Ruby,
# for example "map", "reduce", "inject", the list goes on. Map,
# for instance, takes the array it's looping over, does something
# to it as defined in your block, and returns an entirely new array.