DEV Community

Beatriz da Silva
Beatriz da Silva

Posted on • Edited on

Dia 1 - #100DaysOfSwift

Swift é uma linguagem type-safe, isso significa que ela obriga o código a respeitar os contratos estabelecidos.

Quando criamos uma variável em Swift não precisamos dizer o tipo da variável, o Swift pode inferir o tipo de acordo com o que for armazenado.

var greeting = "Hello"

Mas se preferir, podemos ser mais explícitos e especificar na declaração da variável o seu tipo:

var greeting: String = "Hello"

Depois disso o valor pode mudar quantas vezes for preciso, mas o tipo da variável não pode mais ser mudado.

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️