mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-06 23:06:49 +02:00
Adds more string operations to ruby doc
This commit is contained in:
@@ -12,7 +12,8 @@ contributors:
|
|||||||
- ["Dzianis Dashkevich", "https://github.com/dskecse"]
|
- ["Dzianis Dashkevich", "https://github.com/dskecse"]
|
||||||
- ["Levi Bostian", "https://github.com/levibostian"]
|
- ["Levi Bostian", "https://github.com/levibostian"]
|
||||||
- ["Rahil Momin", "https://github.com/iamrahil"]
|
- ["Rahil Momin", "https://github.com/iamrahil"]
|
||||||
- ["Gabriel Halley", https://github.com/ghalley"]
|
- ["Gabriel Halley", "https://github.com/ghalley"]
|
||||||
|
- ["Persa Zula", "http://persazula.com"]
|
||||||
---
|
---
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
@@ -107,6 +108,12 @@ placeholder = 'use string interpolation'
|
|||||||
'hello ' + 3 #=> TypeError: can't convert Fixnum into String
|
'hello ' + 3 #=> TypeError: can't convert Fixnum into String
|
||||||
'hello ' + 3.to_s #=> "hello 3"
|
'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
|
# print to the output with a newline at the end
|
||||||
puts "I'm printing!"
|
puts "I'm printing!"
|
||||||
#=> I'm printing!
|
#=> I'm printing!
|
||||||
|
Reference in New Issue
Block a user