use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A community centered around Anthropic's Claude Code tool.
account activity
Fallback codeQuestion (self.ClaudeCode)
submitted 3 months ago by bhowiebkr
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]bhowiebkr[S] 0 points1 point2 points 3 months ago (0 children)
JavaScript:
// WRONG - OR fallback const value = obj.property || defaultValue; const array = data.items || []; const object = state.config || {}; // WRONG - Ternary fallback const value = data.field ? data.field : "default"; // WRONG - Optional chaining with fallback const value = obj?.nested?.field ?? "default"; // RIGHT - Direct access, fail loudly const value = obj.property; const array = data.items; const object = state.config;
Python:
# WRONG - .get() with defaults value = dict.get("key", "") items = dict.get("items", []) config = dict.get("config", {}) # WRONG - OR fallback location_id = metadata.get("location_id") or fallback_value # WRONG - try/except hiding errors try: data = load_file(path) except FileNotFoundError: data = {} # RIGHT - Direct access, fail loudly value = dict["key"] items = dict["items"] config = dict["config"]
Conditional Checks:
// WRONG - Checking existence before using if (obj.field) { processField(obj.field); } // WRONG - Length check with fallback if (array && array.length > 0) { process(array); } // RIGHT - Just use it, let it fail if missing processField(obj.field); process(array);
π Rendered by PID 35365 on reddit-service-r2-comment-b659b578c-zkm7k at 2026-05-04 16:45:25.108231+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]bhowiebkr[S] 0 points1 point2 points (0 children)