Created
October 29, 2009 19:56
-
-
Save stevenharman/221757 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// extremely lame example, but I like the functional aspect of it. | |
// also, combining the bool/func pairs into objects (strategies) might | |
// be a nice way to cordon off the coupling. Oh, and the naming could | |
// much improved, which would help greatly with readability. | |
var use_public_forums = | |
new Dictionary<bool, Func<IEnumerable<Forum>, IEnumerable<Forum>>> | |
{ | |
{true, forums => forums.Where(forum => !forum.IsPrivate)}, | |
{false, forums => forums} | |
}; | |
// usage: | |
var other_forums = use_public_forums[includePublic](allForums); | |
var filtered_forums = other_forums.Union(myForums); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment