Reputation: 2845
I'm trying to test out some of the code I write from a book, and created a ruby script to do so.
Right now, I'm supposed to use either shift, push, pop, or unshift to reverse the order of a string.
To do this, I wrote ->
#!/usr/bin/env ruby
def reverse(string)
reverse = []
string.split.each do | char |
reverse.unshift(char)
end
reverse.join
end
reverse("Hello")
When I run the script in command line though, nothing returns ->
Stepans-MacBook-Pro-2:atlas stepan$ /Users/stepan/Desktop/ruby_tester.rb
Stepans-MacBook-Pro-2:atlas stepan$
What's happening here?
Upvotes: 0
Views: 140