RosettaCodeData/Task/Assertions/Nemerle/assertions-2.nemerle

13 lines
563 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
using Nemerle.Assertions;
class SampleClass
{
2026-04-30 12:34:36 -04:00
public SomeMethod (input : list[int]) : int
requires input.Length > 0 // requires keyword indicates precondition,
2023-07-01 11:58:00 -04:00
// there can be more than one condition per method
2026-04-30 12:34:36 -04:00
{ ... }
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
public AnotherMethod (input : string) : list[char]
ensures value.Length > 0 // ensures keyword indicates postcondition
{ ... } // value is a special symbol that indicates the method's return value
2023-07-01 11:58:00 -04:00
}