- p
Debugging print p!
- p! can be useful, especially for debugging prints as it includes the name of the variable.
- Here we see a simple string printed and then a slightly more complex data-structure.
examples/intro/debugging_print.cr
name = "Foo" person = { name: "Foo", number: 42, yesno: true, fruits: ["apple", "banana", "peach"], address: { "street" => "Main str.", "city" => "Capital", "country" => "Country", }, } puts name p name p! name pp! name puts "" puts person p person p! person pp! person
Foo "Foo" name # => "Foo" name # => "Foo" {name: "Foo", number: 42, yesno: true, fruits: ["apple", "banana", "peach"], address: {"street" => "Main str.", "city" => "Capital", "country" => "Country"}} {name: "Foo", number: 42, yesno: true, fruits: ["apple", "banana", "peach"], address: {"street" => "Main str.", "city" => "Capital", "country" => "Country"}} person # => {name: "Foo", number: 42, yesno: true, fruits: ["apple", "banana", "peach"], address: {"street" => "Main str.", "city" => "Capital", "country" => "Country"}} person # => {name: "Foo", number: 42, yesno: true, fruits: ["apple", "banana", "peach"], address: {"street" => "Main str.", "city" => "Capital", "country" => "Country"}}