Skip to content
Hello, World
step 1/5

Reading — step 1 of 5

Learn

~1 min readGetting Started

Swift programs are surprisingly free of ceremony. The top-level code of a .swift file IS the program — no need for a main function.

print("Hello, World!")
print("Ship That Code")

print adds a newline. To skip the newline, pass terminator: "". To print to stderr, use FileHandle.standardError.write(...).

Swift is statically typed but heavily uses inference. The compiler enforces value semantics by default — assigning a struct or array creates a copy, not a reference. That's a major design choice and one of the things that makes Swift code easier to reason about.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…