2 ms·
>If your code reads do_something_to_foo(foo), then very often usually it really ought to be foo.do_something() Personally I'd make an exception when using exte
by contravariant 11y ago
>If your code reads do_something_to_foo(foo), then very often usually it really ought to be foo.do_something()
Personally I'd make an exception when using extension methods in C#. If you make an extension method which looks (schematically) as follows:
add_to_cart(this item, Cart cart) {
cart.add(item);
return item;
}
You can write code that looks like:
item.add_to_cart(cart)
.check_availability()
.do_something_else()
.etc()
Well, this example isn't the best, but you get the general idea.