Mercurial > repos > other > SevenLanguagesInSevenWeeks
changeset 2:369e7cdf3ddf
Add comments to code and document output
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 02 Jan 2017 20:26:32 +0000 |
parents | a8cac0e9b666 |
children | 38f4a671cfa4 |
files | 1-Ruby/each-irb.output 1-Ruby/each-ruby.output 1-Ruby/each.rb |
diffstat | 3 files changed, 33 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/1-Ruby/each-irb.output Mon Jan 02 20:26:32 2017 +0000 @@ -0,0 +1,21 @@ +each.rb(main):001:0> #! /usr/bin/env ruby +each.rb(main):002:0* +each.rb(main):003:0* # Declare an array of strings (like many languages, +each.rb(main):004:0* # single quotes are *not* interpolated) +each.rb(main):005:0* properties = [ 'object oriented', 'duck typed', 'productive', 'fun'] +=> ["object oriented", "duck typed", "productive", "fun"] +each.rb(main):006:0> +each.rb(main):007:0* # Call the Each function with a code block. +each.rb(main):008:0* # Name each parameter "property" and output it +each.rb(main):009:0* # "puts" is like printf - it will *put* a *s*tring to the screen +each.rb(main):010:0* properties.each { | property | puts "Ruby is #{property}." } +Ruby is object oriented. +Ruby is duck typed. +Ruby is productive. +Ruby is fun. +=> ["object oriented", "duck typed", "productive", "fun"] +each.rb(main):011:0> +each.rb(main):012:0* # Note: irb output after properties.each is content of properties +each.rb(main):013:0* +each.rb(main):013:0> +=> nil
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/1-Ruby/each-ruby.output Mon Jan 02 20:26:32 2017 +0000 @@ -0,0 +1,4 @@ +Ruby is object oriented. +Ruby is duck typed. +Ruby is productive. +Ruby is fun.
--- a/1-Ruby/each.rb Mon Jan 02 20:18:44 2017 +0000 +++ b/1-Ruby/each.rb Mon Jan 02 20:26:32 2017 +0000 @@ -1,5 +1,12 @@ #! /usr/bin/env ruby +# Declare an array of strings (like many languages, +# single quotes are *not* interpolated) properties = [ 'object oriented', 'duck typed', 'productive', 'fun'] -properties.each { | property | puts "Ruby is #{property}." } \ No newline at end of file +# Call the Each function with a code block. +# Name each parameter "property" and output it +# "puts" is like printf - it will *put* a *s*tring to the screen +properties.each { | property | puts "Ruby is #{property}." } + +# Note: irb output after properties.each is content of properties