Skip to content

Instantly share code, notes, and snippets.

@jkirkpatrick24
Created July 19, 2016 17:45
Show Gist options
  • Select an option

  • Save jkirkpatrick24/7f5c25345435bbde53c7a6e4ecd33b3f to your computer and use it in GitHub Desktop.

Select an option

Save jkirkpatrick24/7f5c25345435bbde53c7a6e4ecd33b3f to your computer and use it in GitHub Desktop.
Interactive Ruby (Practice)
2.3.0 :001 > def say_hi(name)
2.3.0 :002?> "Hi, #{name}"
2.3.0 :003?> end
=> :say_hi
2.3.0 :004 > say_hi("James")
=> "Hi, James"
2.3.0 :005 >
2.3.0 :006 >
2.3.0 :007 > myarray = [0,0,0,0]
=> [0, 0, 0, 0]
2.3.0 :008 > myarray
=> [0, 0, 0, 0]
2.3.0 :009 > my_array = [1,2,3,4,7,6]
=> [1, 2, 3, 4, 7, 6]
2.3.0 :010 > my_array.sort
=> [1, 2, 3, 4, 6, 7]
2.3.0 :011 > my_array
=> [1, 2, 3, 4, 7, 6]
2.3.0 :012 > my_array.sort!
=> [1, 2, 3, 4, 6, 7]
2.3.0 :013 > my_array
=> [1, 2, 3, 4, 6, 7]
2.3.0 :014 > my_array.each {|n| puts n}
1
2
3
4
6
7
=> [1, 2, 3, 4, 6, 7]
2.3.0 :027 > Math.sqrt(1282)
=> 35.805027579936315
2.3.0 :028 > Time.now
=> 2016-07-19 17:28:54 +0000
2.3.0 :029 > Array.new(10, 'beessssst')
=> ["beessssst", "beessssst", "beessssst", "beessssst", "beessssst", "beessssst", "beessssst", "beessssst", "beessssst", "beessssst"]
2.3.0 :030 > include Math
=> Object
2.3.0 :031 > sqrt 64
=> 8.0
2.3.0 :032 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment