WarnUnusedResult

The WarnUnusedResult aspect marks a method's result as being essential, causing the compiler to emit an error if the method is called without using or checking the result.

The aspect has no effect on the generated code; it only forces the compiler to emit a warning on the call site.

Note: On Swift, this is the default behavior for methods returning values, and the Swift-standard @discardableResult aspect can be used to reverse this.

[WarnUnusedResult]
method GetCount: Int32; 
begin
end;
[WarnUnusedResult]
public int GetCount()
{
}
public func GetCount() -> Integer {
}
@WarnUnusedResult
public int GetCount()
{
}

See Also

  • NoReturn Aspect
  • nil Discardable Expression in Oxygene
  • _ Discardable Expression in C# and Swift