Skip to content

Instantly share code, notes, and snippets.

@marcel-ploch
Last active May 3, 2022 12:33
Show Gist options
  • Save marcel-ploch/304ab73cb14bb4546de1b15fe709ef59 to your computer and use it in GitHub Desktop.
Save marcel-ploch/304ab73cb14bb4546de1b15fe709ef59 to your computer and use it in GitHub Desktop.
// Erweitere die Klasse string um die NumberParsing Extension
extension NumberParsing on String {
int parseInt() {
return int.parse(this);
}
String parseFloat() {
return double.parse(this).toStringAsFixed(2);
}
String changeDirection() {
return this.split('').reversed.join();
}
// ···
}
void main() {
print('42'.parseInt()); // Rufe die Extension auf
print('42'.parseFloat());
print('Marcel'.changeDirection());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment