changeset 16:8d46064c9afc

Be a nice Ruby user and follow block convention for do/end vs {}
author IBBoard <dev@ibboard.co.uk>
date Tue, 03 Jan 2017 20:38:45 +0000
parents ebb19742b98f
children 61dfac9a058a
files 1-Ruby/arrays-irb.output 1-Ruby/arrays.rb 1-Ruby/object-all-things-2-irb.output 1-Ruby/object-all-things-2.rb 1-Ruby/truthiness-irb.output 1-Ruby/truthiness.rb
diffstat 6 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/1-Ruby/arrays-irb.output	Tue Jan 03 20:36:16 2017 +0000
+++ b/1-Ruby/arrays-irb.output	Tue Jan 03 20:38:45 2017 +0000
@@ -35,11 +35,11 @@
 arrays.rb(main):016:0> puts "All funky non-ASCII methods for arrays:"
 All funky non-ASCII methods for arrays:
 => nil
-arrays.rb(main):017:0> [].methods.each { |method| 
+arrays.rb(main):017:0> [].methods.each do |method| 
 arrays.rb(main):018:1* 	if method !~ /[a-z]/
 arrays.rb(main):019:2> 		puts method
 arrays.rb(main):020:2> 	end
-arrays.rb(main):021:1> }
+arrays.rb(main):021:1> end
 ==
 []
 []=
--- a/1-Ruby/arrays.rb	Tue Jan 03 20:36:16 2017 +0000
+++ b/1-Ruby/arrays.rb	Tue Jan 03 20:38:45 2017 +0000
@@ -14,11 +14,11 @@
 puts "as is assignment to an array! [1].methods.include?(:[]=) = #{[1].methods.include?(:[]=)}"
 puts ""
 puts "All funky non-ASCII methods for arrays:"
-[].methods.each { |method| 
+[].methods.each do |method| 
 	if method !~ /[a-z]/
 		puts method
 	end
-}
+end
 
 puts ""
 puts "Arrays are also stacks with push() and pop() methods!"
--- a/1-Ruby/object-all-things-2-irb.output	Tue Jan 03 20:36:16 2017 +0000
+++ b/1-Ruby/object-all-things-2-irb.output	Tue Jan 03 20:38:45 2017 +0000
@@ -2,10 +2,10 @@
 object-all-things-2.rb(main):002:0* 
 object-all-things-2.rb(main):003:0* objects = [ 4, 3.14, 'Pi', 'π', false, true ]
 => [4, 3.14, "Pi", "π", false, true]
-object-all-things-2.rb(main):004:0> objects.each { |obj|
+object-all-things-2.rb(main):004:0> objects.each do |obj|
 object-all-things-2.rb(main):005:1* 	puts "#{obj} (#{obj.class})"
 object-all-things-2.rb(main):006:1> 	obj.methods.each { |method| puts "    #{method}" }
-object-all-things-2.rb(main):007:1> }
+object-all-things-2.rb(main):007:1> end
 4 (Fixnum)
     to_s
     inspect
--- a/1-Ruby/object-all-things-2.rb	Tue Jan 03 20:36:16 2017 +0000
+++ b/1-Ruby/object-all-things-2.rb	Tue Jan 03 20:38:45 2017 +0000
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby
 
 objects = [ 4, 3.14, 'Pi', 'π', false, true ]
-objects.each { |obj|
+objects.each do |obj|
 	puts "#{obj} (#{obj.class})"
 	obj.methods.each { |method| puts "    #{method}" }
-}
+end
--- a/1-Ruby/truthiness-irb.output	Tue Jan 03 20:36:16 2017 +0000
+++ b/1-Ruby/truthiness-irb.output	Tue Jan 03 20:38:45 2017 +0000
@@ -3,11 +3,11 @@
 truthiness.rb(main):003:0* values = [ true, false, 1, 0, -1, 'some string', '', nil ]
 => [true, false, 1, 0, -1, "some string", "", nil]
 truthiness.rb(main):004:0> 
-truthiness.rb(main):005:0* values.each { |val|
+truthiness.rb(main):005:0* values.each do |val|
 truthiness.rb(main):006:1* 	text = if val == nil then "nil" else "'#{val}'" end
 truthiness.rb(main):007:1> 	puts "Val #{text} is truthy" if val
 truthiness.rb(main):008:1> 	puts "Val #{text} is falsy" unless val
-truthiness.rb(main):009:1> }
+truthiness.rb(main):009:1> end
 Val 'true' is truthy
 Val 'false' is falsy
 Val '1' is truthy
--- a/1-Ruby/truthiness.rb	Tue Jan 03 20:36:16 2017 +0000
+++ b/1-Ruby/truthiness.rb	Tue Jan 03 20:38:45 2017 +0000
@@ -2,8 +2,8 @@
 
 values = [ true, false, 1, 0, -1, 'some string', '', nil ]
 
-values.each { |val|
+values.each do |val|
 	text = if val == nil then "nil" else "'#{val}'" end
 	puts "Val #{text} is truthy" if val
 	puts "Val #{text} is falsy" unless val
-}
+end