Sha256: de2538d9b2404d8aed86582cc4b9e8baf4ac810050d897bc21d8983cc8b12665

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

#### Circular Structs

This example shows structs that make a circular reference.

```show.rb```:
```ruby
require 'debug_helper'

MyStruct = Struct.new(:a, :b, :c)
struct_0 = MyStruct.new(0, 1, 2)
struct_1 = MyStruct.new(3, 4, 5)
struct_0.a = struct_1
struct_1.a = struct_0
DebugHelper.show(struct_0, 'My circular struct')
```

The output shows details of the structs.

The circular reference is not followed.

```show.yaml```:
```yaml
---
MyStruct (message='My circular struct'):
  size: 3
  Member 0:
    Name:
      Symbol:
        to_s: a
        size: 1
        encoding: !ruby/encoding US-ASCII
    Value:
      MyStruct:
        size: 3
        Member 0:
          Name:
            Symbol:
              to_s: a
              size: 1
              encoding: !ruby/encoding US-ASCII
          Value: 'MyStruct #<struct MyStruct a=#<struct MyStruct a=#<struct MyStruct:...>,
            b=4, c=5>, b=1, c=2>'
        Member 1:
          Name:
            Symbol:
              to_s: b
              size: 1
              encoding: !ruby/encoding US-ASCII
          Value: Fixnum 4
        Member 2:
          Name:
            Symbol:
              to_s: c
              size: 1
              encoding: !ruby/encoding US-ASCII
          Value: Fixnum 5
  Member 1:
    Name:
      Symbol:
        to_s: b
        size: 1
        encoding: !ruby/encoding US-ASCII
    Value: Fixnum 1
  Member 2:
    Name:
      Symbol:
        to_s: c
        size: 1
        encoding: !ruby/encoding US-ASCII
    Value: Fixnum 2
```

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
debug_helper-1.8.0 markdown/readme/classes/struct/circular/show.md