Tag: methods

56 votes
6 answers
2.1K views
Convert string[] to int[] in one line of code using LINQ

I have an array of integers in string form: var arr = new string[] { "1", "2", "3", "4" }; I need to an arr

avatar
Karolyn
0 1 0 9
asked 07 September, 2021
49 votes
10 answers
1.2K views
Which method performs better: .Any() vs .Count() > 0?

in the System.Linq namespace, we can now extend our IEnumerable's to have the Any() and Count() extension

avatar
Luis
0 1 0 9
asked 07 September, 2021
55 votes
8 answers
2.6K views
How to normalize a NumPy array to within a certain range?

After doing some processing on an audio or image array, it needs to be normalized within a range before it can

avatar
Basil
0 1 0 9
asked 07 September, 2021
62 votes
21 answers
2.6K views
Why is there no ForEach extension method on IEnumerable?

Inspired by another question asking about the missing Zip function: Why is there no ForEach extension method o

avatar
Ali
0 1 0 9
asked 07 September, 2021
58 votes
25 answers
2.9K views
What is the difference between __str__ and __repr__?

What is the difference between __str__ and __repr__ in Python?

avatar
Nereida
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
2.3K views
Difference between staticmethod and classmethod

What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?

avatar
Chaya
0 1 0 9
asked 07 September, 2021
66 votes
25 answers
564 views
Does Java support default parameter values?

I came across some Java code that had the following structure: public MyParameterizedFunction(String param1,

avatar
Keila
0 1 0 9
asked 07 September, 2021
52 votes
30 answers
2.2K views
Is Java "pass-by-reference" or "pass-by-value"?

I always thought Java uses pass-by-reference. However, I've seen a blog post that claims that Java uses p

avatar
Emilia
0 1 0 9
asked 07 September, 2021