Created
September 1, 2015 16:58
-
-
Save malisbad/9d603585a2b5dbf975c6 to your computer and use it in GitHub Desktop.
LHL W1D2 Exercise
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
2.1.3 :001 > def say_hi(name) | |
2.1.3 :002?> "Hi, #{name}" | |
2.1.3 :003?> end | |
=> :say_hi | |
2.1.3 :004 > say_hi("Matt") | |
=> "Hi, Matt" | |
2.1.3 :005 > my_array=[5,3,7,2] | |
=> [5, 3, 7, 2] | |
2.1.3 :006 > my_array.sort | |
=> [2, 3, 5, 7] | |
2.1.3 :007 > my_array | |
=> [5, 3, 7, 2] | |
2.1.3 :008 > my_array.sort! | |
=> [2, 3, 5, 7] | |
2.1.3 :009 > an_array = ['Hello', 'nurse', 'and', 'world'] | |
=> ["Hello", "nurse", "and", "world"] | |
2.1.3 :010 > an_array.each {|word| puts word } | |
Hello | |
nurse | |
and | |
world | |
=> ["Hello", "nurse", "and", ""world"] | |
2.1.3 :011 > include Math | |
=> Object | |
2.1.3 :012 > Math.sqrt(144) | |
=> 12.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment