Created
April 21, 2010 09:12
-
-
Save alexrothenberg/373606 to your computer and use it in GitHub Desktop.
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
# In DOS type | |
### cd \workshop | |
### mkdir ruby_exercises | |
### cd ruby_exercises | |
# Open the e editor | |
### e . | |
# Create a new file called string_exercise.rb | |
################################################### | |
### EXERCISE 1 | |
#Take a string an make it lower case | |
def exercise1 my_string | |
my_string.downcase.reverse | |
end | |
puts '### EXERCISE 1' | |
puts exercise1 'Ruby Rocks' | |
puts exercise1('IT REALLY DOES') | |
puts exercise1 "I'm telling you the TRUTH!!!" | |
################################################### | |
### EXERCISE 2 | |
#Take a string an make it lower case | |
def exercise2 my_string | |
my_string.reverse.split(' ') | |
end | |
puts '### EXERCISE 2' | |
puts exercise2 'Ruby Rocks' | |
puts exercise2 'Ruby Rocks'.inspect | |
puts exercise2('Ruby Rocks').inspect | |
puts exercise2('IT REALLY DOES').inspect | |
puts exercise2("I'm telling you the TRUTH!!!").inspect | |
################################################### | |
### EXERCISE 3 | |
#Make something fun | |
def exercise3 my_string | |
"I think that #{my_string} is FUN!!!" | |
end | |
puts '### EXERCISE 3' | |
puts exercise3 'Football' | |
puts exercise3('Ruby') | |
puts exercise3 "this workshop" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment