Skip to content

dkhasel/maybe-d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

maybe-d

Simple syntactic sugar for a Maybe-like experience. Maybe(T) is just one small step toward a world without null.

Example usage:

import maybe.d;

Maybe!string maybeReturnsString( bool shouldReturnString )
{
    if( shouldReturnString )
    {
        return just!string("foo");
    }
    else
    {
        return nothing!string;
    }
}

// prints "the string is foo"
writeln( "the string is " ~ maybeReturnsString(true).getOrElse("bar") );

// prints "the string is bar"
writeln( "the string is " ~ maybeReturnsString(false).getOrElse("bar") );

About

Provides a Maybe-like data type and helpers, in the key of D.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages