From 1ae02fc6cf7642911125e088ec5e7ce15552b95d Mon Sep 17 00:00:00 2001 From: Persa Zula Date: Sat, 17 Oct 2015 11:25:05 -0400 Subject: Adds more string operations to ruby doc --- ruby.html.markdown | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'ruby.html.markdown') diff --git a/ruby.html.markdown b/ruby.html.markdown index 0e798706..f4de8038 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -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. -- cgit v1.2.3 From a875e6d589b7e6e8a396417adc001bc0f88e82fd Mon Sep 17 00:00:00 2001 From: Persa Date: Sat, 17 Oct 2015 12:16:14 -0400 Subject: Fixes output on combining strings and operators --- ruby.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ruby.html.markdown') diff --git a/ruby.html.markdown b/ruby.html.markdown index f4de8038..4e9f8aee 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -109,7 +109,7 @@ placeholder = 'use string interpolation' 'hello ' + 3.to_s #=> "hello 3" # Combine strings and operators -'hello ' * 3 #=> "hello hello hello" +'hello ' * 3 #=> "hello hello hello " # Append to string 'hello' << ' world' #=> "hello world" -- cgit v1.2.3