Stepan Parunashvili
Stepan Parunashvili

Reputation: 2845

No return on command line when running Ruby script

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

Answers (1)

Stuart Nelson
Stuart Nelson

Reputation: 4202

You need to output the response. Try puts reverse("Hello").

Upvotes: 1

Related Questions