Skip to content

Instantly share code, notes, and snippets.

@stevenharman
Created October 29, 2009 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenharman/221757 to your computer and use it in GitHub Desktop.
Save stevenharman/221757 to your computer and use it in GitHub Desktop.
// 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