Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Dart

Idiom #249 Declare and assign multiple variables

Define variables a, b and c in a concise way.
Explain if they need to have the same type.

var a = 42, b = "Hello", c = 5.0;

can be different types if using var to declare them. Dart will use type inference to assign the correct types to each variable.
var (a, b, c) = (42, "hello", 5.0);

a, b, and c may have different types.

New implementation...
programming-idioms.org