Advertisement
Guest User

Untitled

a guest
May 24th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. vagrant [vagrant]> irb
  2. 2.3.0 :001 > def say_hi
  3. 2.3.0 :002?> "Hi, #{name}"
  4. 2.3.0 :003?> end
  5. => :say_hi
  6. 2.3.0 :004 > say_hi(vanessa)
  7. NameError: undefined local variable or method `vanessa' for main:Object
  8. from (irb):4
  9. from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
  10. 2.3.0 :005 > say_hi("vanessa")
  11. ArgumentError: wrong number of arguments (given 1, expected 0)
  12. from (irb):1:in `say_hi'
  13. from (irb):5
  14. from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
  15. 2.3.0 :006 > say_hi("vanessa")
  16. ArgumentError: wrong number of arguments (given 1, expected 0)
  17. from (irb):1:in `say_hi'
  18. from (irb):6
  19. from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
  20. 2.3.0 :007 > say_hi ("vanessa")
  21. ArgumentError: wrong number of arguments (given 1, expected 0)
  22. from (irb):1:in `say_hi'
  23. from (irb):7
  24. from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
  25. 2.3.0 :008 > say_hi("vanessa")
  26. ArgumentError: wrong number of arguments (given 1, expected 0)
  27. from (irb):1:in `say_hi'
  28. from (irb):8
  29. from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
  30. 2.3.0 :009 > say_hi
  31. NameError: undefined local variable or method `name' for main:Object
  32. from (irb):2:in `say_hi'
  33. from (irb):9
  34. from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
  35. 2.3.0 :010 > def say_hi
  36. 2.3.0 :011?> "Hi, #{name}"
  37. 2.3.0 :012?> end
  38. => :say_hi
  39. 2.3.0 :013 > say_hi("ness")
  40. ArgumentError: wrong number of arguments (given 1, expected 0)
  41. from (irb):10:in `say_hi'
  42. from (irb):13
  43. from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
  44. 2.3.0 :014 > say_hi(nes)
  45. NameError: undefined local variable or method `nes' for main:Object
  46. from (irb):14
  47. from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
  48. 2.3.0 :015 > def say_hi
  49. 2.3.0 :016?> "Hi, #{Josh}"
  50. 2.3.0 :017?> end
  51. => :say_hi
  52. 2.3.0 :018 > say_hi("Josh")
  53. ArgumentError: wrong number of arguments (given 1, expected 0)
  54. from (irb):15:in `say_hi'
  55. from (irb):18
  56. from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
  57. 2.3.0 :019 > def say_hi(Josh)
  58. 2.3.0 :020?> say_hi("Josh")
  59. 2.3.0 :021?> end
  60. SyntaxError: (irb):19: formal argument cannot be a constant
  61. def say_hi(Josh)
  62. ^
  63. from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
  64. 2.3.0 :022 > def say_hi(Josh)
  65. 2.3.0 :023?> "Hi, #{Josh}"
  66. 2.3.0 :024?> end
  67. SyntaxError: (irb):22: formal argument cannot be a constant
  68. def say_hi(Josh)
  69. ^
  70. from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
  71. 2.3.0 :025 > def say_hi(name)
  72. 2.3.0 :026?> "Hi, #{name}"
  73. 2.3.0 :027?> end
  74. => :say_hi
  75. 2.3.0 :028 > say_hi("Josh")
  76. => "Hi, Josh"
  77. 2.3.0 :029 > myarray = [1,2,3,4]
  78. => [1, 2, 3, 4]
  79. 2.3.0 :030 > myarray.sort
  80. => [1, 2, 3, 4]
  81. 2.3.0 :031 > myarray =[ 5,6,1,2]
  82. => [5, 6, 1, 2]
  83. 2.3.0 :032 > myarray.sort
  84. => [1, 2, 5, 6]
  85. 2.3.0 :033 > myarray
  86. => [5, 6, 1, 2]
  87. 2.3.0 :034 > myarray.sort!
  88. => [1, 2, 5, 6]
  89. 2.3.0 :035 > myarray
  90. => [1, 2, 5, 6]
  91. 2.3.0 :036 > anarray = ["ness", "darren", "family", "brunei"]
  92. => ["ness", "darren", "family", "brunei"]
  93. 2.3.0 :037 > an_array.each { |word| puts word}
  94. NameError: undefined local variable or method `an_array' for main:Object
  95. Did you mean? anarray
  96. from (irb):37
  97. from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
  98. 2.3.0 :038 > anarray.each { |word| puts word}
  99. ness
  100. darren
  101. family
  102. brunei
  103. => ["ness", "darren", "family", "brunei"]
  104. 2.3.0 :039 > Math.sqrt(1268)
  105. => 35.608987629529715
  106. 2.3.0 :040 > Math.sqrt(1282)
  107. => 35.805027579936315
  108. 2.3.0 :041 > Time.now
  109. => 2016-05-24 19:10:51 +0000
  110. 2.3.0 :042 > time.now
  111. NameError: undefined local variable or method `time' for main:Object
  112. from (irb):42
  113. from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
  114. 2.3.0 :043 > Array.new(100, "bee")
  115. => ["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"]
  116. 2.3.0 :044 > include Math
  117. => Object
  118. 2.3.0 :045 > sqrt 64
  119. => 8.0
  120. 2.3.0 :046 >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement