Last active
May 3, 2022 12:33
-
-
Save marcel-ploch/304ab73cb14bb4546de1b15fe709ef59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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