Dart Runes first
Syntax & Examples

Runes.first property

The `first` property in Dart returns the first element of the Rune sequence.


Syntax of Runes.first

The syntax of Runes.first property is:

 int first 

This first property of Runes returns the first element.

Return Type

Runes.first returns value of type int.



✐ Examples

1 First rune

In this example,

  1. We create a sequence of Unicode code points runes from the string 'Hello'.
  2. We access the first element using the first property.
  3. We then print the first rune to standard output.

Dart Program

void main() {
  Runes runes = Runes('Hello');
  int firstRune = runes.first;
  print('First rune: $firstRune');
}

Output

First rune: 72

2 First emoji

In this example,

  1. We create a sequence of Unicode code points emojis from the string '👋🏽🚀🌟'.
  2. We access the first element using the first property.
  3. We then print the first emoji to standard output.

Dart Program

void main() {
  Runes emojis = Runes('👋🏽🚀🌟');
  int firstEmoji = emojis.first;
  print('First emoji: $firstEmoji');
}

Output

First emoji: 128075

3 First number

In this example,

  1. We create a sequence of Unicode code points numbers from the string '12345'.
  2. We access the first element using the first property.
  3. We then print the first number to standard output.

Dart Program

void main() {
  Runes numbers = Runes('12345');
  int firstNumber = numbers.first;
  print('First number: $firstNumber');
}

Output

First number: 49

Summary

In this Dart tutorial, we learned about first property of Runes: the syntax and few working examples with output and detailed explanation for each example.