diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-06-04 16:13:59 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-06-04 16:13:59 +0100 |
| commit | 117e22cdd0d6b20968fc39e2c8e1a7e6c73e9e73 (patch) | |
| tree | 0d1d5fedf73a322b9f72ff6593739f0188714f2c /Mammoth/Couscous/java/util/Optional.cs | |
| parent | f5a729ceda45b534c7cc709097cf6d115afa52fa (diff) | |
Use single instance of None
Diffstat (limited to 'Mammoth/Couscous/java/util/Optional.cs')
| -rw-r--r-- | Mammoth/Couscous/java/util/Optional.cs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Mammoth/Couscous/java/util/Optional.cs b/Mammoth/Couscous/java/util/Optional.cs index f295688..b5be056 100644 --- a/Mammoth/Couscous/java/util/Optional.cs +++ b/Mammoth/Couscous/java/util/Optional.cs @@ -16,6 +16,11 @@ namespace Mammoth.Couscous.java.util } internal class None<T> : Optional<T> { + internal static readonly None<T> Instance = new None<T>(); + + private None() { + } + public bool isPresent() { return false; } @@ -92,7 +97,7 @@ namespace Mammoth.Couscous.java.util { internal static Optional<T> empty<T>() { - return new None<T>(); + return None<T>.Instance; } internal static Optional<T> of<T>(T value) |
