Need a good name for an extension method
-
A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):
public static int Min(this int a, int max)
{
return (a > max) ? max : a;
}But what would be a good name for this (which I've tentatively named "MinDelta":
public static int MinDelta(this int a, int delta)
{
return a > a + delta ? a + delta : a;
}Suggestions? Humor? Marc
V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):
public static int Min(this int a, int max)
{
return (a > max) ? max : a;
}But what would be a good name for this (which I've tentatively named "MinDelta":
public static int MinDelta(this int a, int delta)
{
return a > a + delta ? a + delta : a;
}Suggestions? Humor? Marc
V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
MinnieBannister
But then you'll have to find a place for aHenryCrun
, and maybe anEccles
and aBluebottle
.I wanna be a eunuchs developer! Pass me a bread knife!
-
Frank. Call it Frank.
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a fucking golf cart.
"I don't know, extraterrestrial?" "You mean like from space?" "No, from Canada." If software development were a circus, we would all be the clowns.I'm Frank! No, wait -- I'm Tiger Woods, aren't I? Oh, no, I've got it: I'm Spartacus! ... Brian?
I wanna be a eunuchs developer! Pass me a bread knife!
-
-D***Size -Asians -AlphaBetaGamma -DeltaDelta -MyFunction1 -Method -AGreaterB -Minimi -IHaveNoIdeaHowToNameThisThing just to hand you a couple ideas
if(this.signature != "")
{
MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
}
else
{
MessageBox.Show("404-Signature not found");
}HobbyProggy wrote:
MyFunction1
That's gotta be the winner!
I wanna be a eunuchs developer! Pass me a bread knife!
-
MinDelta->Fall / MaxDelta->Climb?
GeoGame for Windows Phone | The Lounge Explained In 5 Minutes
Mladen Janković wrote:
MinDelta->Fall / MaxDelta->Climb?
Ooh, I like that! :) Marc
V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
0x01AA wrote:
Minimize
Ah, I think we have a winner! Marc
V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):
public static int Min(this int a, int max)
{
return (a > max) ? max : a;
}But what would be a good name for this (which I've tentatively named "MinDelta":
public static int MinDelta(this int a, int delta)
{
return a > a + delta ? a + delta : a;
}Suggestions? Humor? Marc
V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
minifyoufeellikeit
Rules for playing Javascript frameworks. 1. You can't win. 2. You can't break even. 3. You can't get out of the game.
-
0x01AA wrote:
Minimize
Ah, I think we have a winner! Marc
V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):
public static int Min(this int a, int max)
{
return (a > max) ? max : a;
}But what would be a good name for this (which I've tentatively named "MinDelta":
public static int MinDelta(this int a, int delta)
{
return a > a + delta ? a + delta : a;
}Suggestions? Humor? Marc
V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
Add Inc or Increment
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):
public static int Min(this int a, int max)
{
return (a > max) ? max : a;
}But what would be a good name for this (which I've tentatively named "MinDelta":
public static int MinDelta(this int a, int delta)
{
return a > a + delta ? a + delta : a;
}Suggestions? Humor? Marc
V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
Keep it simple and traditional: DeltayMcDeltaface
-
-D***Size -Asians -AlphaBetaGamma -DeltaDelta -MyFunction1 -Method -AGreaterB -Minimi -IHaveNoIdeaHowToNameThisThing just to hand you a couple ideas
if(this.signature != "")
{
MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
}
else
{
MessageBox.Show("404-Signature not found");
} -
A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):
public static int Min(this int a, int max)
{
return (a > max) ? max : a;
}But what would be a good name for this (which I've tentatively named "MinDelta":
public static int MinDelta(this int a, int delta)
{
return a > a + delta ? a + delta : a;
}Suggestions? Humor? Marc
V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
Marc Clifton wrote:
I know there's Math.Min, but I want a fluent implementation, so just go with it
FMI, what's not fluent about Math.Min? Or is that a fancy way of saying you wan to be able to chain it?
Jeremy Falcon
-
DeltaBurke
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):
public static int Min(this int a, int max)
{
return (a > max) ? max : a;
}But what would be a good name for this (which I've tentatively named "MinDelta":
public static int MinDelta(this int a, int delta)
{
return a > a + delta ? a + delta : a;
}Suggestions? Humor? Marc
V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
namespace CliftoniusMagnus
{
public enum Int32CompareResult
{
Equal,
LessThan,
GreaterThan
}public static class Int32Extensions { public static int I32Min(this int i, int limit) { return I32Compare(i, limit) == Int32CompareResult.LessThan ? i : limit; } public static int I32PlusDeltaMin(this int i, int delta) { return I32Min(i, i + delta); } public static Int32CompareResult I32Compare(this int i1, int i2) { return i1 == i2 ? Int32CompareResult.Equal : i1 < 12 ? Int32CompareResult.LessThan : Int32CompareResult.GreaterThan; } }
}
The style here reflects my preference (ghost of Simonyi ?) for making "Type and Intent" salient at all times, and ... whenever possible ... writing functions that are multi-purpose. However, I'd only write such functions if I anticipated I might have a need to add some functionality to them; otherwise, they're just duplicating functions in .Math. And, yes, this style is not spicy. cheers, Bill
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
-
A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):
public static int Min(this int a, int max)
{
return (a > max) ? max : a;
}But what would be a good name for this (which I've tentatively named "MinDelta":
public static int MinDelta(this int a, int delta)
{
return a > a + delta ? a + delta : a;
}Suggestions? Humor? Marc
V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
Hi, Marc, I am a little wary of extension methods on 'Int32 because of compiler error #CS0023
caused by an attempt to use/call the method on a negative integer; while this can be worked around by putting the negative value in parens; I find that tedious.
var x = -100.SomeExtension(10); // will not compile
var y = (-100).SomeExtension(10); // will compile
var z = 100.SomeExtension(10); // will compileI regret to say this same error occurs in VS 2017, using the latest FrameWork version.
I assume this is an operator execution precedence issue ?
I have not evaluated whether this error occurs with other numeric Types; I hypothesize it will.
cheers, Bill
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008