Ruby-Pair/main.rb
#to_s method, formats the output to be the same as a Racket instruction
to_s method, formats the output to be the same as a Racket instruction
to_s method formats the output to be the same as a Racket instruction
def to_s
    if @value2.nil?
      format('(%s)', @value1.to_s)
    elsif @value2.is_a? Pair
      var = @value2.to_s
      var[0] = ''
      var[var.length - 1] = '' if var[var.length - 1] == ')'
      format('(%s %s)', @value1.to_s, var)
    else
      format('(%s . %s)', @value1.to_s, @value2.to_s)
    end
  end
def to_s if @value2 . nil? format ( '(%s)' , @value1 . to_s ) elsif @value2 . is_a? Pair var = @value2 . to_s var [ 0 ] = '' var [ var . length - 1 ] = '' if var [ var . length - 1 ] == ')' format ( '(%s %s)' , @value1 . to_s , var ) else format ( '(%s . %s)' , @value1 . to_s , @value2 . to_s ) end end
to_s method, formats the output to be the same as a Racket instruction
to_s method formats the output to be the same as a Racket instruction