Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Bloody
Mar 3, 2013

i assume default of a decimal? is 0?

Adbot
ADBOT LOVES YOU

30 TO 50 FERAL HOG
Mar 2, 2005



HoboMan posted:

i understand the concept of nullables. i still just get a kick out the idea that you add a question mark to a type that may or may not have a value. also i don't check for hasvalue and and just cast it into a proper decimal immediately, i'm sure the behavior of this is exactly what i want it to be (lol). do i really need to put in an if to check hasvalue and set it to 0 if it don't? because i don't want to.

edit: just saw that you said like half of the entries in the db have a null

yeah you need to be checking that poo poo in some way son

30 TO 50 FERAL HOG fucked around with this message at 20:53 on Mar 23, 2016

HoboMan
Nov 4, 2010

unrelated, but gently caress css

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


http://www.drinchev.com/blog/alert-npm-modules-hijacked/

so someone has been going through all the unpublished npm modules and claiming them for himself. npm's managers say that the guy is perfectly friendly and won't be using the hijacked modules for illicit code tho

https://twitter.com/seldo/status/712673227630313472

i'm not really sure what the npm managers think they're loving doing but this is really retarded

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
If npm goes away then so does bower. gently caress bower

Bloody
Mar 3, 2013

Soricidus
Oct 21, 2010
freedom-hating statist shill

Condiv posted:

i'm not really sure what the npm managers think they're loving doing but this is really retarded

welcome to the future of programming

triple sulk
Sep 17, 2014



https://medium.com/@mproberts/a-discussion-about-the-breaking-of-the-internet-3d4d2a83aa4d#.co2maojvr

lol just lol

Shaggar
Apr 26, 2006

HoboMan posted:

sounds reasonable but i'm a idiot who is not qualified for this job and asking to get things purchased puts me under scrutiny

e:

like half the records in the db are null in that column

so then it needs to be nullable and you need to check for values.

HoboMan
Nov 4, 2010

i thought i was done, but then i opened the page in chrome instead of ie and gently caress

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

i wish i could say this was the dumbest thing ive read on medium

Potassium Problems
Sep 28, 2001

Shaggar posted:

so then it needs to be nullable and you need to check for values.

So do you know the under-the-hood reason why this works? Seriously curious.

code:
var nullableInts = new int?[] { 0, 3, null, 5, 2, null };
int? sum = nullableInts.Sum();  // sum = 10
Also even though Sum<int?>() returns an int?, if every item in the array is null, sum is not null, and the value is 0.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

CRIP EATIN BREAD posted:

i wish i could say this was the dumbest thing ive read on 👊🍆

HoboMan
Nov 4, 2010

Lone_Strider posted:

Also even though Sum<int?>() returns an int?, if every item in the array is null, sum is not null, and the value is 0.

this is the behavior i was getting and why i thought it was fine to just cast it after

Shaggar
Apr 26, 2006

Lone_Strider posted:

So do you know the under-the-hood reason why this works? Seriously curious.

code:
var nullableInts = new int?[] { 0, 3, null, 5, 2, null };
int? sum = nullableInts.Sum();  // sum = 10
Also even though Sum<int?>() returns an int?, if every item in the array is null, sum is not null, and the value is 0.

interestingly this is counter to the expected behavior of normal operators. According to this: https://msdn.microsoft.com/en-us/library/2cf62fcy.aspx#Anchor_4 any operation that involves a null nullable should return null. but in the source code for sum you can see there are explicit handlings for nullable types so that null values are ignored.

raminasi
Jan 25, 2005

a last drink with no ice
ok that's weird and counterintuitive behavior but I assume it's because they wanted empty sequences to sum to zero

Shaggar
Apr 26, 2006
if you look at the documentation for Sum<decimal?> it says in the notes it ignores nulls.

Shaggar
Apr 26, 2006

quote:

The result does not included values that are null.
heh

HoboMan
Nov 4, 2010

hah! guess i'm not so terrible after all!

cya l8ter shitlords i'm off to the good programmers thread

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
God, it would suck to be a node developer right now (or really anytime)

*opens Visual Studio* :smith:

Shaggar
Apr 26, 2006
visual studio is pretty good but the auto complete sucks and resharper's autocomplete sucks too but is also slow. why cant anyone just replicated eclipse autocomplete??

akadajet
Sep 14, 2003


pro-click

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod



threatening to sic lawyers on someone: a "polite" request

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

GrumpyDoctor posted:

ok that's weird and counterintuitive behavior but I assume it's because they wanted empty sequences to sum to zero

it makes sense: you start with zero and add all the non-nulls to it. the only question is why does it return a nullable?

gonadic io
Feb 16, 2011

>>=

HappyHippo posted:

it makes sense: you start with zero and add all the non-nulls to it. the only question is why does it return a nullable?

empty list?

akadajet
Sep 14, 2003

Condiv posted:

threatening to sic lawyers on someone: a "polite" request

ya everyone involved in this was an idiot about it

jesus WEP
Oct 17, 2004


gonadic io posted:

empty list?
it initialises sum as 0 and then loops through the elements in the list, so an empty list would return 0

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik

Finster Dexter posted:

God, it would suck to be a node developer right now (or really anytime)

*opens Visual Studio* :smith:

I work at a node heavy place and nobody here even noticed this happened.

FamDav
Mar 29, 2008

GrumpyDoctor posted:

ok that's weird and counterintuitive behavior but I assume it's because they wanted empty sequences to sum to zero

it's only counterintuitive because just sum does that

Shaggar
Apr 26, 2006

HappyHippo posted:

it makes sense: you start with zero and add all the non-nulls to it. the only question is why does it return a nullable?

it kind of makes sense, but its counter to the functionality of the + operator so the method signature having a nullable return makes sense in a world where sum works like +, but in a world where sum works differently then theres no reason for it to be a nullable return.

its inconsistent either way and since the current sum implementation would have to change in a breaking way to be consistent with the operator, it would make more sense to change the return to a non-nullable

akadajet
Sep 14, 2003


reminder about what kik messanger is:
https://goo.gl/RHSVZZ

Potassium Problems
Sep 28, 2001

GrumpyDoctor posted:

ok that's weird and counterintuitive behavior but I assume it's because they wanted empty sequences to sum to zero

Yeah even knowing this, I think I'd still rather see col.Where(n => n.HasValue).Sum(n => n.Value) than col.Sum() when it came to nullable types

thx shaggar

edit: or col.Sum(n => n.GetValueOrDefault(0)), I'll have to keep that in mind

HoboMan
Nov 4, 2010

it's because otherwise it would then return null if any value in the list was null and that's loving useless

e: but yeah it should just return a non-nullable type

HoboMan fucked around with this message at 23:44 on Mar 23, 2016

Flat Daddy
Dec 3, 2014

by Nyc_Tattoo

akadajet posted:

reminder about what kik messanger is:
https://goo.gl/RHSVZZ

either you messed up the link or this is the first completely unsolicited LMGTFY ive ever seen

akadajet
Sep 14, 2003

Flat Daddy posted:

either you messed up the link or this is the first completely unsolicited LMGTFY ive ever seen

it's a link to news articles about kik yes. mostly pedophiles using it to target children.

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


akadajet posted:

it's a link to news articles about kik yes. mostly pedophiles using it to target children.

of course it's used for that. it was made by people who willingly use nodejs and probably talk about ephebobobilia

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

HoboMan posted:

it's because otherwise it would then return null if any value in the list was null and that's loving useless

But that's kind of the behavior I expect from my option types...

If you take null as analogous to ⊥, i.e. "I don't know what this value is", then you can't really say that you know the value of the sum when you don't know all the individual values. If you knew that the value was 0, it would be 0 instead of null.

Progressive JPEG
Feb 19, 2003

fritz posted:

i gotta say i was hoping that the thing exported was something like "abcdefghijklmnoqrstuvwxyz" or "abcdefghjiklmnopqrstuvwxyz"

maybe that's what they fixed in 1.0.1

Progressive JPEG fucked around with this message at 03:21 on Mar 24, 2016

raminasi
Jan 25, 2005

a last drink with no ice
in c#, 0 + null is null. it's weird for sum to not just be addition reduced over the sequence. I can see why they did it, but it's weird.

Adbot
ADBOT LOVES YOU

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


GrumpyDoctor posted:

in c#, 0 + null is null. it's weird for sum to not just be addition reduced over the sequence. I can see why they did it, but it's weird.

:confused: how does 0 + null = null make any sense at all?

null + null rightfully doesn't compile, so 0 cannot be being cast to null

fake edit: i just tried 0 + null in ideone and it comes back as 0, which is the sane result (though lovely cause it's implicitly casting null to int)

  • Locked thread