Updated examples for Function.apply()
Examples updated
Closes https://github.com/dart-lang/sdk/pull/48115
https://github.com/dart-lang/sdk/pull/48115
GitOrigin-RevId: 5ea352418b1776092e7991fe153abdc4cb939fb4
Change-Id: I2ef9cdaff0afdcc329d83873f2bd5c7aceec2543
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227140
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
diff --git a/sdk/lib/core/function.dart b/sdk/lib/core/function.dart
index 1151354..ea2d614 100644
--- a/sdk/lib/core/function.dart
+++ b/sdk/lib/core/function.dart
@@ -20,16 +20,33 @@
///
/// Example:
/// ```dart
- /// Function.apply(foo, [1, 2, 3], {#f: 4, #g: 5});
- /// ```
+ /// void printWineDetails(int vintage, {String? country, String? name}) {
+ /// print('Name: $name, Country: $country, Vintage: $vintage');
+ /// }
///
- /// gives exactly the same result as
- /// ```dart
- /// foo(1, 2, 3, f: 4, g: 5).
+ /// void main() {
+ /// Function.apply(
+ /// printWineDetails, [2018], {#country: 'USA', #name: 'Dominus Estate'});
+ /// }
+ ///
+ /// // Output of the example is:
+ /// // Name: Dominus Estate, Country: USA, Vintage: 2018
/// ```
///
/// If [positionalArguments] is null, it's considered an empty list.
/// If [namedArguments] is omitted or null, it is considered an empty map.
+ ///
+ /// ```dart
+ /// void helloWorld() {
+ /// print('Hello world!');
+ /// }
+ ///
+ /// void main() {
+ /// Function.apply(helloWorld, null);
+ /// }
+ /// // Output of the example is:
+ /// // Hello world!
+ /// ```
external static apply(Function function, List<dynamic>? positionalArguments,
[Map<Symbol, dynamic>? namedArguments]);