⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.133
Server IP:
185.119.109.197
Server:
Linux managedhosting.chostar.me 5.15.0-160-generic #170-Ubuntu SMP Wed Oct 1 10:06:56 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.1.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
ri
/
3.0.0
/
system
/
View File Name :
page-dig_methods_rdoc.ri
U:RDoc::TopLevel[ i I"dig_methods.rdoc:EFcRDoc::Parser::Simpleo:RDoc::Markup::Document:@parts[(S:RDoc::Markup::Heading: leveli: textI"Dig Methods;To:RDoc::Markup::BlankLine o:RDoc::Markup::Paragraph;[I"JRuby's +dig+ methods are useful for accessing nested data structures.;T@ o; ;[I"Consider this data:;To:RDoc::Markup::Verbatim;[I"item = { ;TI" id: "0001", ;TI" type: "donut", ;TI" name: "Cake", ;TI" ppu: 0.55, ;TI" batters: { ;TI" batter: [ ;TI"* {id: "1001", type: "Regular"}, ;TI", {id: "1002", type: "Chocolate"}, ;TI", {id: "1003", type: "Blueberry"}, ;TI". {id: "1004", type: "Devil's Food"} ;TI" ] ;TI" }, ;TI" topping: [ ;TI"% {id: "5001", type: "None"}, ;TI"' {id: "5002", type: "Glazed"}, ;TI"& {id: "5005", type: "Sugar"}, ;TI"/ {id: "5007", type: "Powdered Sugar"}, ;TI"9 {id: "5006", type: "Chocolate with Sprinkles"}, ;TI"* {id: "5003", type: "Chocolate"}, ;TI"% {id: "5004", type: "Maple"} ;TI" ] ;TI"} ;T:@format0o; ;[I"+Without a +dig+ method, you can write:;To;;[I"8item[:batters][:batter][1][:type] # => "Chocolate" ;T;0o; ;[I"(With a +dig+ method, you can write:;To;;[I"
"Chocolate" ;T;0o; ;[I"8Without a +dig+ method, you can write, erroneously ;TI"N(raises
NoMethodError (undefined method `[]' for nil:NilClass)
):;To;;[I"'item[:batters][:BATTER][1][:type] ;T;0o; ;[I"XWith a +dig+ method, you can write (still erroneously, but avoiding the exception):;To;;[I"4item.dig(:batters, :BATTER, 1, :type) # => nil ;T;0S; ; i;I"Why Is +dig+ Better?;T@ o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o; ;[I"6It has fewer syntactical elements (to get wrong).;To;;0;[o; ;[I"It reads better.;To;;0;[o; ;[I"