Created
March 19, 2013 20:12
-
-
Save PragTob/5199653 to your computer and use it in GitHub Desktop.
Rails Girls Berlin Project group Thursdays tryruby console log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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".reverse | |
=> "iboT" | |
Result is a String instead of a Number. | |
> "Tobi".length | |
=> 4 | |
Success! | |
> "Tobi".length * 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".reverse | |
=> "ybuR" | |
Try calling 40.reverse | |
> 40.reverse | |
=> #<NoMethodError: undefined method `reverse' for 40:Fixnum> | |
Oh no! | |
> "40".reverse | |
=> "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".length | |
=> 4 | |
Result is a Fixnum instead of an Array. | |
> "Tobi".length.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).round | |
=> 31 | |
Result is a Fixnum instead of an Array. | |
> (30.3).round | |
=> 30 | |
Result is a Fixnum instead of an Array. | |
> [] | |
=> [] | |
Success! | |
> [12, 47, 35] | |
=> [12, 47, 35] | |
Success! | |
> [12, 47, 35].max | |
=> 47 | |
Success! | |
> [12, 47, 35, 99].max | |
=> 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" | |
> ticket.sort | |
=> [12, 35, 47] | |
> ticket | |
=> [12, 47, 35] | |
> sorted = ticket.sort | |
=> [12, 35, 47] | |
> sorted | |
=> [12, 35, 47] | |
> ticket | |
=> [12, 47, 35] | |
> ticket.sort! | |
=> [12, 35, 47] | |
> ticket | |
=> [12, 35, 47] | |
> ticket.shuffle | |
=> [35, 12, 47] | |
> ticket | |
=> [12, 35, 47] | |
> ticket.shuffle! | |
=> [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 "string" | |
=> "string" | |
> print ticket | |
=> #<NameError: undefined local variable or method `ticket' for main:Object> | |
> ticket = [12, 47, 35] | |
=> [12, 47, 35] | |
> print ticket | |
=> "[12, 47, 35]" | |
> abvc | |
=> #<NameError: undefined local variable or method `abvc' for main:Object> | |
> next | |
> poem['toast'] = 'green 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.reverse | |
=> ".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['toast'] = 'green 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.reverse | |
["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.reverse.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.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 | |
Success! | |
> next | |
> poem.downcase | |
=> "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["Gravity's Rainbow"] = :splendid | |
=> :splendid | |
Success! | |
> books | |
=> {"Gravity's Rainbow"=>:splendid} | |
> books["Passionate Programmer"] = :splendid | |
=> :splendid | |
> books["Effi Briest"] = :awful | |
=> :awful | |
> books["Clean Code"] = :splendid | |
=> :splendid | |
> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment