惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
Martin Fowler
Martin Fowler
Vercel News
Vercel News
U
Unit 42
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
Y
Y Combinator Blog
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog RSS Feed
N
Netflix TechBlog - Medium
GbyAI
GbyAI
F
Fortinet All Blogs
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
M
MIT News - Artificial intelligence
D
Docker
IT之家
IT之家
Stack Overflow Blog
Stack Overflow Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Pressure-Testing My Own Explanations — A Swift Writing Ex...
Gamya · 2026-06-23 · via DEV Community

Gamya

When you've worked with a concept long enough, there's a gap that can quietly open up between "I know how this works" and "I can explain exactly why this works, including the edge cases that trip people up." Writing a tutorial closes that gap fast — readers will hit exactly those edge cases, and a good article needs to anticipate them.

Before publishing the article on Swift function parameters — external vs internal names, the _ underscore, default values — I ran a quick exercise: a batch of small function snippets, some valid and some subtly broken, each one checked line by line. The goal wasn't to test whether I understood parameters — it was to stress-test the explanations themselves, and make sure they'd hold up against exactly the kind of "looks right but isn't" code a learner might write. 🍥

Why Bother With This, If the Concept Is Already Familiar

Knowing a rule and being able to anticipate every way someone might misapply it are different things. Parameter labels are a great example — the rules themselves are short, but the ways they interact (single name vs two names, _ vs labeled, what happens at the call site vs inside the function) create a surprising number of combinations. Going through deliberately-broken snippets is a fast way to make sure an explanation covers the combinations that actually confuse people, not just the ones that are easy to describe.

A Few Snippets Worth Including in the Article

The "two names that look like one" trap

func makeBurger(withCheese: Bool) {
    if cheese {
        print("Here's a cheeseburger")
    } else {
        print("Here's a regular burger")
    }
}

This is a great teaching example precisely because it looks fine at a glance — cheese reads as obviously related to withCheese. But Swift doesn't do "obviously related." withCheese is the parameter name (both external and internal, since only one name was given), and cheese was never declared. This is exactly the kind of mistake a learner makes when they understand the concept of parameters but haven't internalized that Swift matches names exactly, not by similarity.

The "duplicate label" trap

func formatLength(length length: Int) {
    print("That measures \(length)cm.")
}
formatLength(95)

This one's useful because it stacks two separate issues: the length length: syntax is invalid when both names are identical, and the call site formatLength(95) is missing a required label even if the declaration were fixed. A good explanation needs to address both — it's easy to fix one and assume the snippet is now correct, when a second issue remains.

The one most likely to surprise readers: skipping return

func square(_ number: Int) -> Int {
    number * number
}

No return keyword, and it's completely valid — Swift allows a function body that's a single expression to implicitly return that value. For an article, this is worth calling out explicitly with its own example, separate from the surrounding explanation, because seeing it in isolation — without context cluing the reader in that something special is happening — is closer to how a reader will encounter it "in the wild" in someone else's code.

What This Exercise Is Really For

The value here isn't "I learned something new about Swift." It's that going through concrete pass/fail examples, one at a time, surfaces the gap between a correct mental model and an explanation that anticipates where readers will get confused. The cheese/withCheese example is the clearest case — the underlying rule (Swift matches names exactly) is simple to state, but an explanation that doesn't show why a plausible-looking mismatch fails won't actually prevent the mistake.

Where AI Was Useful Here

For this kind of exercise, having a tool that could generate a steady stream of varied snippets — some valid, some subtly broken in different ways — and walk through each one line by line on request made it easy to cover a wider range of "near-miss" cases quickly than working through a fixed set of pre-written examples would have. It functioned less like a teacher and more like a sparring partner for testing explanations against fresh cases.

Worth Doing Before Publishing

If you write technical tutorials, this is a cheap pre-publish check: take the rule you're about to explain, and try to generate a handful of snippets that are almost correct but fail for a specific, nameable reason. If you can't immediately produce several, your explanation might be covering the easy 80% and leaving readers to discover the other 20% the hard way — in the comments. 🌸