Results for “method”
Small, practical examples. Search by task or narrow things down below.
Await an asynchronous method result
C#: Use Task<T> for an async operation with a typed result.
C#✓ Tested
Call a component method from an event
Call a component method from an event with a standalone Angular component and explicit browser behavior.
Angular✓ Tested
Implement a method on a struct
Implement a method on a struct in a complete Rust program using the standard library.
Rust✓ Tested
Return multiple named values from a method
C#: Named value tuples give lightweight field names without a separate class.
C#✓ Tested
Validate an argument at a method boundary
C#: ThrowIfNegative gives callers an explicit argument error for an invalid range.
C#✓ Tested
Attach behavior to a struct
Attach behavior to a struct using a complete Go program with explicit sample inputs.
Go✓ Tested
Mutate a struct through a pointer receiver
Mutate a struct through a pointer receiver using a complete Go program with explicit sample inputs.
Go✓ Tested
Display an integer as unsigned
Java: Use unsigned conversion methods when interpreting a fixed-width bit pattern.
Java✓ Tested
Distinguish an own property from an inherited one
JavaScript: Object.hasOwn avoids depending on an object’s possibly shadowed hasOwnProperty method.
JavaScript✓ Tested
Distinguish an own property from an inherited one
TypeScript: Object.hasOwn avoids depending on an object’s possibly shadowed hasOwnProperty method.
TypeScript✓ Tested
Expose observation without exposing resolution
jQuery: promise returns an interface without resolve or reject methods.
jQuery✓ Tested
Filter and transform an array
Keep active objects and extract their names.
filter✓ Tested