File: struct.rb

package info (click to toggle)
ruby-hamster 3.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,932 kB
  • sloc: ruby: 16,915; makefile: 4
file content (9 lines) | stat: -rw-r--r-- 205 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
class Struct
  # Implement Struct#to_h for Ruby interpreters which don't have it
  # (such as MRI 1.9.3 and lower)
  unless method_defined?(:to_h)
    def to_h
      Hash[each_pair.to_a]
    end
  end
end