Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vagrant [vagrant]> irb
- 2.3.0 :001 > def say_hi
- 2.3.0 :002?> "Hi, #{name}"
- 2.3.0 :003?> end
- => :say_hi
- 2.3.0 :004 > say_hi(vanessa)
- NameError: undefined local variable or method `vanessa' for main:Object
- from (irb):4
- from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- 2.3.0 :005 > say_hi("vanessa")
- ArgumentError: wrong number of arguments (given 1, expected 0)
- from (irb):1:in `say_hi'
- from (irb):5
- from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- 2.3.0 :006 > say_hi("vanessa")
- ArgumentError: wrong number of arguments (given 1, expected 0)
- from (irb):1:in `say_hi'
- from (irb):6
- from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- 2.3.0 :007 > say_hi ("vanessa")
- ArgumentError: wrong number of arguments (given 1, expected 0)
- from (irb):1:in `say_hi'
- from (irb):7
- from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- 2.3.0 :008 > say_hi("vanessa")
- ArgumentError: wrong number of arguments (given 1, expected 0)
- from (irb):1:in `say_hi'
- from (irb):8
- from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- 2.3.0 :009 > say_hi
- NameError: undefined local variable or method `name' for main:Object
- from (irb):2:in `say_hi'
- from (irb):9
- from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- 2.3.0 :010 > def say_hi
- 2.3.0 :011?> "Hi, #{name}"
- 2.3.0 :012?> end
- => :say_hi
- 2.3.0 :013 > say_hi("ness")
- ArgumentError: wrong number of arguments (given 1, expected 0)
- from (irb):10:in `say_hi'
- from (irb):13
- from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- 2.3.0 :014 > say_hi(nes)
- NameError: undefined local variable or method `nes' for main:Object
- from (irb):14
- from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- 2.3.0 :015 > def say_hi
- 2.3.0 :016?> "Hi, #{Josh}"
- 2.3.0 :017?> end
- => :say_hi
- 2.3.0 :018 > say_hi("Josh")
- ArgumentError: wrong number of arguments (given 1, expected 0)
- from (irb):15:in `say_hi'
- from (irb):18
- from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- 2.3.0 :019 > def say_hi(Josh)
- 2.3.0 :020?> say_hi("Josh")
- 2.3.0 :021?> end
- SyntaxError: (irb):19: formal argument cannot be a constant
- def say_hi(Josh)
- ^
- from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- 2.3.0 :022 > def say_hi(Josh)
- 2.3.0 :023?> "Hi, #{Josh}"
- 2.3.0 :024?> end
- SyntaxError: (irb):22: formal argument cannot be a constant
- def say_hi(Josh)
- ^
- from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- 2.3.0 :025 > def say_hi(name)
- 2.3.0 :026?> "Hi, #{name}"
- 2.3.0 :027?> end
- => :say_hi
- 2.3.0 :028 > say_hi("Josh")
- => "Hi, Josh"
- 2.3.0 :029 > myarray = [1,2,3,4]
- => [1, 2, 3, 4]
- 2.3.0 :030 > myarray.sort
- => [1, 2, 3, 4]
- 2.3.0 :031 > myarray =[ 5,6,1,2]
- => [5, 6, 1, 2]
- 2.3.0 :032 > myarray.sort
- => [1, 2, 5, 6]
- 2.3.0 :033 > myarray
- => [5, 6, 1, 2]
- 2.3.0 :034 > myarray.sort!
- => [1, 2, 5, 6]
- 2.3.0 :035 > myarray
- => [1, 2, 5, 6]
- 2.3.0 :036 > anarray = ["ness", "darren", "family", "brunei"]
- => ["ness", "darren", "family", "brunei"]
- 2.3.0 :037 > an_array.each { |word| puts word}
- NameError: undefined local variable or method `an_array' for main:Object
- Did you mean? anarray
- from (irb):37
- from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- 2.3.0 :038 > anarray.each { |word| puts word}
- ness
- darren
- family
- brunei
- => ["ness", "darren", "family", "brunei"]
- 2.3.0 :039 > Math.sqrt(1268)
- => 35.608987629529715
- 2.3.0 :040 > Math.sqrt(1282)
- => 35.805027579936315
- 2.3.0 :041 > Time.now
- => 2016-05-24 19:10:51 +0000
- 2.3.0 :042 > time.now
- NameError: undefined local variable or method `time' for main:Object
- from (irb):42
- from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- 2.3.0 :043 > Array.new(100, "bee")
- => ["bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee"]
- 2.3.0 :044 > include Math
- => Object
- 2.3.0 :045 > sqrt 64
- => 8.0
- 2.3.0 :046 >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement