611 questions
3
votes
4
answers
167
views
How to get the result code when using .NET in powershell script?
I'm trying to get the result code from a running a file search in a powershell function.
I'm using .NET for efficiency, and I don't want to compromise that. Now I am trying to obtain some kind of ...
2
votes
1
answer
112
views
Why can for...in loop run on undefined?
Why does this code work?
for (const i in undefined) {}
From for...in - JavaScript | MDN:
The for...in statement iterates over all enumerable string properties of an object (ignoring properties keyed ...
0
votes
1
answer
75
views
How to extract inline calculation when working with enumerables in Ruby?
I am trying to make a FizzBuzz in Ruby based on an enumerable. It works when I inline the calculation:
numb_array = (0..100)
numb_array.select { |numb|
if numb % 2 == 0 && numb % 3 == 0
...
0
votes
1
answer
187
views
How to create an "enumerable" decorator for accessor methods in TypeScript
I'm trying to make an @enumerable decorator that will expose properties defined via accessor methods.
A function to do this on instances of the class is fairly trivial:
// This works great when called ...
0
votes
3
answers
122
views
Iterating Properties in Object Oriented JavaScript
I am trying to develop a more object oriented approach to my programming but have run into a problem. I thought it would be useful to group related properties in an object together with methods that ...
0
votes
2
answers
167
views
Merge two enumerables whilst keeping the order defined by either source
I need to merge two enumerables while keeping the relative order of items as defined in the source enumerables.
For example, if enumerable1 contains "foxtrot", "uniform" and "...
0
votes
1
answer
729
views
Undefined method `name' for an instance of Array (NoMethodError)
I am trying to add an element into an instance of array by using push(<<) to insert variables new_name and new_origin into ingredients array but I am receiving this error: undefined method `name'...
0
votes
1
answer
86
views
AutoMapper collections of strings to object properties in a collection of objects
I'm trying to map an object containing enumerable collections of strings into an object containing an enumerable collection objects whose properties contain the data in those collections.
Consider the ...
8
votes
1
answer
6k
views
What is a collection expression when instantiating a List<T>
I don't understand what Intellisense is suggesting as a replacement for my existing code (pictured here)
In case the image gets deleted later, the Intellisense suggestion that is pictured suggests ...
0
votes
0
answers
52
views
Can I order an IEnumerable in C#, using "OrderBy()" and some boolean? [duplicate]
As mentioned in this other post, there are two ways to alter the direction of the ordering of a C# List (or any Enumerable):
use the OrderByDescending() method.
add .Reverse() at the end.
In my code,...
0
votes
4
answers
321
views
C# implement Iterator Pattern and early return empty enumerable if one iterator is not valid
I want to extract two foreach´s which iterate over mostly the same list but one has an early exit if one element is not valid and the other will only be executed if the other collected the data ...
0
votes
0
answers
50
views
How to get a string[] as value from a Dictionary<int, string[]> regroup all value
I have a Dictionary<int, string[]>.
And I want to know, if with the functions of Enumerable/Collection it's possible to get in one line "approximatly", to regroup all string[] value in ...
0
votes
3
answers
150
views
C# can cast LINQ Aggregate to double to output factorial, this works for integer up to 12
I want to fill the list with factorials using linq.
I got this, this works up to 12. I assume it's because of the integer range. But I couldn't retype it to double. Can this be easily modified (...
-3
votes
1
answer
38
views
RegEx numeric list
He have a text with a numeric list and he would like a regex for have each items in a array.
For give an exemple :
text= "Bien sûr, voici trois idées d'articles qui pourraient être intéressants ...
3
votes
4
answers
257
views
How can I find all chains of intersected rectangles
I have an array of rectangles. Some of them might intersect, forming a pair:
While others might intersect, forming a chain:
And, of course, some of them might be alone.
I want to form a list that ...