It’s turned into a killer feature for me. I write lots of parsing code, extracting info from laws and statutes. dbg’s ability to show intermediate values in a pipeline is amazing for helping me understand where my code went wrong.
E.g., here I’m trying to extract the Chapter range, 90 - 130 but I’ve got a bug.
range_string =
raw_string
|> String.split("-", parts: 3)
|> at(2)
|> trim()
|> String.split()
|> at(1)
|> String.split("(")
|> at(0)
|> dbg
[lib/crawlers/ors/parser.ex:52: Parser.extract_chapter_range/1]
raw_string #=> "Volume : 03 - Landlord-Tenant, Domestic Relations, Probate - Chapters 90-130 (36)"
|> String.split("-", parts: 3) #=> ["Volume : 03 ", " Landlord",
"Tenant, Domestic Relations, Probate - Chapters 90-130 (36)"]
|> at(2) #=> "Tenant, Domestic Relations, Probate - Chapters 90-130 (36)"
|> trim() #=> "Tenant, Domestic Relations, Probate - Chapters 90-130 (36)"
|> String.split() #=> ["Tenant,", "Domestic", "Relations,", "Probate", "-", "Chapters",
"90-130 (36)"]
|> at(1) #=> "Domestic"
|> String.split("(") #=> ["Domestic"]
|> at(0) #=> "Domestic"
Seeing this helped me quickly decide to just use a Regex.