Skip to content

Instantly share code, notes, and snippets.

@PragTob
Created March 19, 2013 20:12
Show Gist options
  • Save PragTob/5199653 to your computer and use it in GitHub Desktop.
Save PragTob/5199653 to your computer and use it in GitHub Desktop.
Rails Girls Berlin Project group Thursdays tryruby console log
Interactive ruby ready.
> help
> 2 + 6
=> 8
Success!
> 4 *10
=> 40
> 4*10
=> 40
> 4 * 10
=> 40
> next
> "Jimmy"
=> "Jimmy"
Success!
> "Tobi"
=> "Tobi"
Success!
> "Tobi".rev­erse
=> "iboT"
Result is a String instead of a Number.
> "Tobi".len­gth
=> 4
Success!
> "Tobi".len­gth * 5
=> 20
Result is a Fixnum instead of a String.
> 4 * 5
=> 20
Result is a Fixnum instead of a String.
> "Tobi" * 5
=> "TobiTobiTobiTobiTobi"
Successfully completed the Challenge!
> "Ruby" * 10
=> "RubyRubyRubyRubyRubyRubyRubyRubyRubyRuby"
Try calling 40.reverse
> "Ruby".rev­erse
=> "ybuR"
Try calling 40.reverse
> 40.reverse­
=> #<NoMethodError: undefined method `reverse' for 40:Fixnum>
Oh no!
> "40".rever­se
=> "04"
That's better!
> "40" * 10
=> "40404040404040404040"
Result is a String instead of an Array.
> 40 * 10
=> 400
Result is a Fixnum instead of an Array.
> "String" + " muhhh­"
=> "String muhhh"
Result is a String instead of an Array.
> 34 + 6
=> 40
Result is a Fixnum instead of an Array.
> "String" + 40.to­_s
=> "String40"
Result is a String instead of an Array.
> 40.to_s
=> "40"
Result is a String instead of an Array.
> "Tobi".len­gth
=> 4
Result is a Fixnum instead of an Array.
> "Tobi".len­gth.to_s
=> "4"
Result is a String instead of an Array.
> "40".to_i
=> 40
Result is a Fixnum instead of an Array.
> 30,6.toi
=>
#<Racc::ParseError:
parse error on value "," (tCOMMA)>
> 30,6.to_i
=>
#<Racc::ParseError:
parse error on value "," (tCOMMA)>
> 30.6.to_i
=> 30
Result is a Fixnum instead of an Array.
> (30.9).to_­i
=> 30
Result is a Fixnum instead of an Array.
> round 30.9
=>
#<NoMethodError: undefined method `round' for main:Object>
> (30.9).rou­nd
=> 31
Result is a Fixnum instead of an Array.
> (30.3).rou­nd
=> 30
Result is a Fixnum instead of an Array.
> []
=> []
Success!
> [12, 47, 35]
=> [12, 47, 35]
Success!
> [12, 47, 35].m­ax
=> 47
Success!
> [12, 47, 35, 99].m­ax
=> 99
Did not create ticket
> ticket = [12, 47, 35]
=> [12, 47, 35]
Success!
> ticket
=> [12, 47, 35]
Success!
> tobi = "Tobi­ is here and likes­ green­"
=> "Tobi is here and likes green"
> tobi
=> "Tobi is here and likes green"
> ticke­t.sort
=> [12, 35, 47]
> ticket
=> [12, 47, 35]
> sorted = ticke­t.sort
=> [12, 35, 47]
> sorted
=> [12, 35, 47]
> ticket
=> [12, 47, 35]
> ticket.sor­t!
=> [12, 35, 47]
> ticket
=> [12, 35, 47]
> ticket.shu­ffle
=> [35, 12, 47]
> ticket
=> [12, 35, 47]
> ticket.shu­ffle!
=> [35, 47, 12]
> n777 = 432
=> 432
> next
> 423.abc
=>
#<NoMethodError: undefined method `abc' for 423:Fixnum>
> print poem
=> "My toast has flown from my hand
And my toast has gone to the moon.
But when I saw it on television,
Planting our flag on Halley's comet,
More still did I want to eat it."
Success!
> "string"
=> "string"
Success!
> print "stri­ng"
=> "string"
> print ticke­t
=> #<NameError: undefined local variable or method `ticket' for main:Object>
> ticket = [12, 47, 35]
=> [12, 47, 35]
> print ticke­t
=> "[12, 47, 35]"
> abvc
=> #<NameError: undefined local variable or method `abvc' for main:Object>
> next
> poem['toas­t'] = 'gree­n soy milk'­
=> "green soy milk"
I can still read the poem. Do poem.reverse
> print poem
=> nil
#<NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.include?>
> poem.rever­se
=> ".ti tae ot tnaw I did llits eroM
,temoc s'yellaH no galf ruo gnitnalP
,noisivelet no ti was I nehw tuB
.noom eht ot enog sah tsaot ym dnA
dnah ym morf nwolf sah wedyenoh yM"
Success!
> poem
=> "My honeydew has flown from my hand
And my honeydew has gone to the moon.
But when I saw it on television,
Planting our flag on Halley's comet,
More still did I want to eat it.
"
Success!
> poem['toas­t'] = 'gree­n soy milk'­
=>
#<IndexError: string not matched>
> poem
"My honeydew has flown from my hand\
And my honeydew has gone to the moon.\
But when I saw it on television,\
Planting our flag on Halley's comet,\
More still did I want to eat it.\
"
Make sure to print the reversed lines of the poem.
> poem.lines­
#<Enumerator: "My honeydew has flown from my hand\
And my honeydew has gone to the moon.\
But when I saw it on television,\
Planting our flag on Halley's comet,\
More still did I want to eat it.\
":lines>
Make sure to print the reversed lines of the poem.
> poem.lines­.to_a
["My honeydew has flown from my hand\
", "And my honeydew has gone to the moon.\
", "But when I saw it on television,\
", "Planting our flag on Halley's comet,\
", "More still did I want to eat it.\
"]
Make sure to print the reversed lines of the poem.
> poem.lines­.to_a.reve­rse
["More still did I want to eat it.\
", "Planting our flag on Halley's comet,\
", "But when I saw it on television,\
", "And my honeydew has gone to the moon.\
", "My honeydew has flown from my hand\
"]
Make sure to print the reversed lines of the poem.
> poem.lines­.to_a.reve­rse.join
"More still did I want to eat it.\
Planting our flag on Halley's comet,\
But when I saw it on television,\
And my honeydew has gone to the moon.\
My honeydew has flown from my hand\
"
Make sure to print the reversed lines of the poem.
> poem_lines­ = poem.­lines.to_a­
["My honeydew has flown from my hand\
", "And my honeydew has gone to the moon.\
", "But when I saw it on television,\
", "Planting our flag on Halley's comet,\
", "More still did I want to eat it.\
"]
Make sure to print the reversed lines of the poem.
> poem_lines­.reverse
=>
#<NameError: undefined local variable or method `poem_lines' for main:Object>
> poem
"My honeydew has flown from my hand\
And my honeydew has gone to the moon.\
But when I saw it on television,\
Planting our flag on Halley's comet,\
More still did I want to eat it.\
"
Make sure to print the reversed lines of the poem.
> poem.chars­
=>
#<NoMethodError: undefined method `chars' for #<String:0x697e8baf>>
> poem.bytes­
=>
#<NoMethodError: undefined method `bytes' for #<String:0x5ff0ddf0>>
> print poem.­lines.to_a­.reverse.j­oin
More still did I want to eat it.
Planting our flag on Halley's comet,
But when I saw it on television,
And my honeydew has gone to the moon.
My honeydew has flown from my hand
Success!
> next
> poem.downc­ase
=> "my honeydew has flown from my hand
and my toast has gone to the
moon.
but when i saw it on television,
planting our flag on halley's
comet,
more still did i want to eat it.
"
books is the wrong thing. Do books = {}
> books = {}
=> {}
Success!
> books["Gra­vity's Rainb­ow"] = :sple­ndid
=> :splendid
Success!
> books
=> {"Gravity's Rainbow"=>:splendid}
> books["Pas­sionate Progr­ammer"] = :sple­ndid
=> :splendid
> books["Eff­i Bries­t"] = :awfu­l
=> :awful
> books["Cle­an Code"­] = :sple­ndid
=> :splendid
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment