Forum: Ruby Difference between pretty_print_cycle and pretty_print.

Posted by Love U Ruby (my-ruby)
on 2013-02-21 16:55
From the link I found the two methods :

 http://apidock.com/ruby/v1_9_3_125/Struct/pretty_print

Struct#pretty_print_cycle and Struct#pretty_print.

Could anyone give me two examples to understand the differences between
them? As I didn't found any documentation.


Thanks
Posted by Hans Mackowiak (hanmac)
on 2013-02-21 17:21
i found this in the code

Object#pretty_print_cycle is used when +obj+ is already
    # printed, a.k.a the object reference chain has a cycle.
Posted by Love U Ruby (my-ruby)
on 2013-02-21 18:29
Hans Mackowiak wrote in post #1098243:
> i found this in the code
>
> Object#pretty_print_cycle is used when +obj+ is already
>     # printed, a.k.a the object reference chain has a cycle.


@Hans Could you give me an example of those to understand the 
differences?


Thanks
Posted by Hans Mackowiak (hanmac)
on 2013-02-21 20:13
what the heck is the problem with "already printed" ??

require "pp"
class A
attr_accessor :data
end

o=A.new
o.data = o

pp o # => #<A:0x00000001e0e178 @data=#<A:0x00000001e0e178 ...>>

a = []
a << a
pp a #=> [[...]]

h = {}
h[h]=h
pp h #=> {{...}=>{...}}


pretty_print_cycle is for making the ... variants
Posted by Marc Heiler (shevegen)
on 2013-02-21 20:36
Hey "Love U Ruby",

Are you still trying to find "weaknesses"?

The official documentation is at:

  http://www.ruby-doc.org/core-1.9.3/Struct.html

Quit using non standard sources already.

I am 100% sure you never had a real need for any of this,
you are just scavenging for percieved "weaknesses", then
you steal the time of other people here!

(See his other comments/threads.)
Posted by Ryan Davis (Guest)
on 2013-02-22 00:28
(Received via mailing list)
On Feb 21, 2013, at 11:36 , Marc Heiler <lists@ruby-forum.com> wrote:

> Hey "Love U Ruby",
>
> Are you still trying to find "weaknesses"?
>
> The official documentation is at:
>
>  http://www.ruby-doc.org/core-1.9.3/Struct.html
>
> Quit using non standard sources already.

To be fair... that's not "standard" any more than apidock is. De facto, 
yes... but not standard.
Posted by Stu (Guest)
on 2013-02-22 01:15
(Received via mailing list)
On Thu, Feb 21, 2013 at 1:36 PM, Marc Heiler <lists@ruby-forum.com> 
wrote:
> I am 100% sure you never had a real need for any of this,
> you are just scavenging for percieved "weaknesses", then
> you steal the time of other people here!
>
> (See his other comments/threads.)
>
> --
> Posted via http://www.ruby-forum.com/.
>

I am also not sure of the sincerity of the OP simply as the questions
are open ended without example of either working, or not working,
code. Also ending each thread with "show me some examples" doesn't
help either. Though I would love to explore the concept of text
processing with high level print formatters while exploring their uses
in the real world via polymorphic view with modular abstraction while
pointing out primitive functions such as inspect and it's relationship
to the c puts function as a simple wrapper to printf while exploring
aliasing with shortform such as p and the Kernel modules extension
syntax to the systems standard in/out and error. But that would
require a bit of effort for an open ended and obtuse question without
a specific issue or use case attached.

With that said "Love U Ruby" may I recommend reading this tutorial on
communication with technical forums with questions pertaining to
learning new programming languages, dialects with programming
environments and  conceptual frameworks without the anti-pattern of
insulting members of the community by either being misinformed now
explaining the issues which your currently having with your project or
motivation to be working the the technology at hand. This venerable
tutorial is located here:
http://www.catb.org/esr/faqs/smart-questions.html

~Stu
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.