Chaos Project

RPG Maker => General Discussion => Topic started by: bigace on October 05, 2013, 11:38:46 am

Title: Whats the difference?
Post by: bigace on October 05, 2013, 11:38:46 am
So I notice a while ago that ruby 1.9.1 has msgbox and I wanted to know what was the difference between:


As far as I can see, both functions look and act the same.
Title: Re: Whats the difference?
Post by: ForeverZer0 on October 05, 2013, 02:22:36 pm
If I remember correctly, "p" is more of a debug tool, it uses the "inspect" method to determine what to output, while "print" (I think just an alias for "pretty_print", uses the standard "to_s" to determine the output.  

Both will be usually the same, but "p" will have a different output if "to_s" is overridden in the class.

test = Array.new

p test
print test

class Array
 
  def to_s
    "ARRAY"
  end
end

p test
print test
Title: Re: Whats the difference?
Post by: bigace on October 05, 2013, 03:13:58 pm
ops I worded that wrong :facepalm:. I fix the OP.
Title: Re: Whats the difference?
Post by: KK20 on October 06, 2013, 02:44:16 pm
Quote from: RMVXA Help File-RGSS Specifications
It is now possible to use editor options to open a console window for debugging output during play testing.
Output to message boxes using the print function and the p function has been abolished due to the aforementioned improvement. These functions have been renamed msgbox and msgbox_p.

So tell me how you are able to get print and msgbox to both work, besides doing something like

def print(*args)
  msgbox(*args)
end
def p(*args)
  msgbox_p(*args)
end
Title: Re: Whats the difference?
Post by: bigace on October 06, 2013, 11:30:12 pm
Okay so it's just a upgrade with a new name.