Project

General

Profile

Bug #11103 ยป ruby-bug.rb

Code to reproduce the problem - sigsve (Sigurd Berg Svela), 04/27/2015 10:06 PM

 
require 'JSON'


class MainClass
attr_reader :mock_input

def initialize(input)
puts "hello"

@mock_input = input

# Print with JSON or puts
puts "-------"
if (mock_input.is_a?(Array))
puts JSON.pretty_generate mock_input
else
puts mock_input
end
puts "-------"

if (!mock_input.is_a?(Array))
puts "Converting to array..."
mock_input = [mock_input]
end

# Print with JSON or puts
puts "-------"
if (mock_input.is_a?(Array))
puts JSON.pretty_generate mock_input
else
puts mock_input
end
puts "-------"
end
end

MainClass.new ["hello", "world"]
    (1-1/1)