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

14 lines
551 B
Text
Raw Permalink Normal View History

2013-10-27 22:24:23 +00:00
using Nemerle.Assertions;
class SampleClass
{
public SomeMethod (input : list[int]) : int
requires input.Length > 0 // requires keyword indicates precondition,
// there can be more than one condition per method
{ ... }
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
}