Connect with me on 'em socials: Twitter: / amantinband LinkedIn: / amantinband GitHub: github.com/amantinband
Пікірлер: 24
@OllyWood688 Жыл бұрын
Great, more ways for me to flex my code-fu and produce unmaintainable masterpieces that I won't remember what they do and how they do it in a year lol :D
@jamesmussett Жыл бұрын
having async still makes it 0, what i find more amusing however is that the following is still valid c#: using System; using System.Runtime.CompilerServices; class await { async async async(async async) => await async; } [AsyncMethodBuilder(typeof(builder))] class async { public awaiter GetAwaiter() => throw null; } class awaiter : INotifyCompletion { public bool IsCompleted => true; public void GetResult() { } public void OnCompleted(Action continuation) { } } class builder { public builder() { } public static builder Create() => throw null; public void SetResult() { } public void SetException(Exception e) { } public void Start(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine => throw null; public async Task => throw null; public void AwaitOnCompleted( ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine => throw null; public void AwaitUnsafeOnCompleted( ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine => throw null; public void SetStateMachine(IAsyncStateMachine stateMachine) => throw null; }
@pagorbunov Жыл бұрын
Following the same logic as with 'var' the output is going to be 0
Working with c# for more than 2 years, learn something new 👍
@reikooters Жыл бұрын
"backwards compatibility with C# before version 3" because of course
@gg15 Жыл бұрын
@amantinband Unrelated: How is your terminal set up? zsh + oh my zsh + what theme? + custom config? Thx!
@amantinband Жыл бұрын
Yup, zsh and oh-my-zsh. The theme is p10k with some customizations, and then I have some plugins for the output colors, vi mode etc, my full configuration is available here: github.com/ amantinband/dotfiles
@pilotboba Жыл бұрын
I'm assuming its oh-my-posh which is cross platform and excellent. (written in go)
@amantinband Жыл бұрын
Nope. On my Mac I use oh-my-zsh 🫣
@pilotboba Жыл бұрын
@@amantinband A Mac - heresy !!!
@gg15 Жыл бұрын
@@amantinband Thank you! I like it.
@williamliu8985 Жыл бұрын
horrible code! M$ should really ban them...
@maxron6514 Жыл бұрын
Fully agreed but They won’t because of their almighty lizardgod called „downwards compatibility“ 😂
@bobweiram6321 Жыл бұрын
Thank god for your comments because I was questioning my own intellect for criticizing this appalling design choice. It means the compiler can no longer help in detecting errors resulting from reserved word ambiguity. The better choice is to flag an error and offer a pragma option to warn instead. This choice favors convenience over correctness, a very bad trade off. Such terrible decisions provides a lot of insight into why Microsoft's products are so shoddy.
@bobweiram6321 Жыл бұрын
@@maxron6514 Yes, but sadly you can have downwards compatibility without allowing unchecked ambiguity.
@piotrc966 Жыл бұрын
0
@bobweiram6321 Жыл бұрын
What a terrible design decision! Allowing new reserved words for variable names in order to maintain backward compatibility, defeats the point of disambiguation. It is likely to make it nearly impossible to detect certain errors when porting old code. The proper way to handle this is with a compiler error with an option to use a pragma to override it with a warning.
@Kann_lol Жыл бұрын
I literally guessed the right answer ez default is 1 on int but we have given default! so its 0
@amantinband Жыл бұрын
Lol
@catsgotmytongue Жыл бұрын
as a professional developer, I'd say there's no excuse to use the c# keywords as names for things so please don't, not even with the @ symbol in front. This usage of c# while possible wouldn't work well for a team. What if I put that same var alias in a global using ? There's a reason we have coding standards.
@amantinband Жыл бұрын
Maybe I should add a “These riddles are meant as brain teasers and a fun way to learn language features, not recommendations” disclaimer
@catsgotmytongue Жыл бұрын
@Amichai Mantinband fine, I would argue you should never see such a scenario, and if you do it's a red flag that the person needs talked to about why you should never do this. The language shouldn't allow the scenario but it does and thanks for pointing out where the compiler fails to prevent the developer from making tragic mistakes for a team.