r/ProgrammerHumor • • Aug 01 '22

>>>print(“Hello, World!”)

Post image
60.8k Upvotes

5.7k comments sorted by

View all comments

Show parent comments

3.6k

u/a-slice-of-toast Aug 01 '22

creates a new record, obviously

1.6k

u/hampshirebrony Aug 01 '22

And was outdated by CD cd = new CD().cd(), which itself was outdated by MP3 mp3 = new MP3().mp3()

206

u/[deleted] Aug 01 '22

[removed] — view removed comment

12

u/shekurika Aug 01 '22

recently had new(()=>new()) in my code x)

6

u/PrevAccLocked Aug 01 '22

Context please?

8

u/shekurika Aug 01 '22

generic that wanted an initalizer function. was meant to be about "VS complains about adding the type in new()" buut I answered to the wrong comment, whoops

23

u/QuestionableSarcasm Aug 01 '22

.net doesn't want you to do anything

not even c#, visual studio or anyone wants you to do it this way or the other way

set up your .editorconfig as you like it and make warnings (or errors, if you prefer), style suggestions and refactoring suggestions to actually mean something

4

u/[deleted] Aug 01 '22

[removed] — view removed comment

5

u/AdamiralProudmore Aug 01 '22

Actually those suggestions come from the Roslyn Analyzers made by the .NET team (the same things that provide intellisense). So you are in both technical and general senses correct in saying "that is what .NET wants".

→ More replies (4)

4

u/MrAmos123 Aug 01 '22

.NET Core prefers the second, I think, due to the use of var. Though, it's likely more to do with the IDE.

Using Rider, if you write Record record = new Record(); Rider wants to replace the first Record with var.

3

u/NearPup Aug 01 '22
var record = new Record();

and

Record record = new Record();

are absolutely identical in terms of what they compile down to, so it's basically entirely down to personal preference / what coding standards you are abiding by.

6

u/MrAmos123 Aug 01 '22 edited Aug 01 '22

Oh yeah, I don't disagree. Just saying for the sake of conversation, really.

But var record = new Record(); > Record record = new(); unless using class field or property then public Record Record { get; set; } = new(); or instatiate within a method is best imo.

3

u/[deleted] Aug 01 '22

This is the way

→ More replies (3)

8

u/[deleted] Aug 01 '22

Except hipsters still use Record record = new Record(); and swear everything else is just not the same.

3

u/ushu3323 Aug 01 '22

Just use Template pattern

2

u/TrustTriiist Aug 01 '22

Why does code have empty brackets in it?

I thought this would do nothing

5

u/Kittycraft0 Aug 01 '22

If you mean parentheses (‘(‘ and ‘)’) then that’s usually calling a function or method with the name being the text right before it. A function or method is a way to call a bunch of lines of code in one line. They can have input(s) which would usually go inside of the parentheses, separated by commas if there is more than one, but if there are no input(s) to said method/function then the parentheses stay there anyways.

4

u/TrustTriiist Aug 01 '22

This makes it very clear, thank you

→ More replies (2)
→ More replies (1)

2

u/enaud Aug 02 '22

The audiophile in me cringes at this

→ More replies (1)
→ More replies (5)

18

u/LordSalem Aug 01 '22

No, it records a new record

2

u/mossybeard Aug 01 '22

Call Guinness

2

u/Does_Not-Matter Aug 01 '22

Does it make the Billboard top 100

2

u/NoseBurner Aug 01 '22

Spins you around.

2

u/findus_l Aug 01 '22

And that verbosity is at the same time the most hated and most appreciated part of Java. Appreciated for teaching, hated for everything else.

2

u/konstantinua00 Aug 01 '22

no, it's high score

→ More replies (3)