question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Overload for TapIf with Func<T, bool> condition

See original GitHub issue

Currently the TapIf extensions only accept a bool parameter for the condition. I think it would be convenient to also have overloads that accept a Func<T, bool> and Func<T, E, bool> for the condition. Should these overloads be added, or are there any reasons for why they’re not there in the first place?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
space-aliencommented, Mar 6, 2020

Ah yes, of course.

So I think your original preferred (second) option may be best after all; it is the most consistent with the approach taken on other extension methods with many signatures (i.e. keep the implementations similar to each other and as clear as possible, to help with maintainability).

if (result.IsSuccess && condition(result.Value))
    return result.Tap(action);
else
    return result;
0reactions
space-aliencommented, Mar 12, 2020

Please take a look at #188 and #174

Read more comments on GitHub >

github_iconTop Results From Across the Web

TapIf() · Issue #135 · vkhorikov/CSharpFunctionalExtensions
I find an overload with Func<T, bool> instead of just bool also handy. It will add the possibility to chain like this: Dog.Create("Lassie") ......
Read more >
Using conditional return type depending on boolean ...
The simplest way to return different types based on a boolean argument would be overloads: function getStatsById(userId: string, ...
Read more >
Untitled
Book club birthday party ideas, So how you doin hippo, Vasatka systems, ... Sommerfuglebusk stiklinger, Overload chart show chat, Tendurek dagi nerede, ...
Read more >
Untitled
Monroe antique car swap meet, Book names for first graders, ... Green arrow comic images, Live in ten action, Osdh acute disease service,...
Read more >
kernel/exynos
The fixup function can correct the problem + by calling debug_object_init ... Y6 Y5 Y4 Y3 Y2 Y1 Y0 + +Note that the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found