[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 5765732.png (35 KB, 1245x224)
35 KB PNG
How would the go equivalent look like
>>
>>109775501
You tell me, I never used go
>>
>>109775501
You could have asked AI but instead you wasted your time.
>>
>>109775766
No, he wasted YOUR time, and we're laughing about it.
>>
>>109775501
result, err := users.Where(func(user User) bool { return user.Score > 50}).Order().Reverse().Skip(2)
>>
>>109776061
N-no please, that doesn't fit with the narrative I was going with! Please delete your post!
>>
>>109775910
nice try OP
>>
>>109775501
I love LINQ
>>
>>109776061
Nice try, but original lambda obviously did not return bool
I assume it's operator overloading into some sort of sql statement type
>>
```go
import (
"cmp"
"slices"
)

result := slices.Clone(users)
result = slices.DeleteFunc(result, func(u User) bool { return u.Score <= 50 })
slices.SortFunc(result, func(a, b User) int { return cmp.Compare(b.Score, a.Score) })
if len(result) > 2 {
result = result[2:]
} else {
result = result[:0]
}
```
>>
>>109778843
fuck are you talking about, in what world does
user => user.Score > 50
not return a bool in js? .Where obviously takes a filter func, and filter funcs work by returning a bool on each indice. .Where returns a slice, on which you could use .Sort. the rest (
.Reverse, .Skip
) are abstracted away because theyre trivial to implement, even though they dont exist in the go std or on those types. the same vibe is completely applicable though.
>>
>>109775501
>.Order()
order by what?
>>
>>109776061
>>109779434
>even though they dont exist in the go std
so, you mean that code that you wrote doesn’t actually work out of the box?
>theyre trivial to implement
then why the fuck aren’t they already implemented out of the box?

Not implementing inheritance in golang was based, but the disdain for common syntax sugar is autistic
>>
>>109779946
>then why the fuck aren’t they already implemented out of the box?
Because adding dumb features just so you can jump on every passing fad is how you get C++.
>>
sorry for wasting your time I figured it out
>>
>>109779434
>js
I thought that's c#.
Still boolean.
>>
>>109779957
I though gotards were creaming themselves over having a "batteries-included" stdlib unlike eg rust, what happened?
>>
>>109779434
What JS, this is fucking C#
>>
>>109775501
what abomination is this
>>
>>109778728
Last word hahahaha



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.