0

Ruby and Arrays

Why is Ruby extensive in array manipulations e.g. adding two arrays, subtracting two arrays, joining, removing duplicates etc unlike other modern programming languages C# or Java?

21st Jul 2017, 4:05 PM
Haider Ali
Haider Ali - avatar
1 ответ
+ 1
Could be a couple reasons: Ruby has 'global functions'. C# and Java do not. You can just make a method to do the same thing for you in C# and Java so it's not a problem. There's also likely some libraries with those methods. This could be a reason since arrays are objects, so you'd have to use a method in them with C# or Java. Not sure if C# supports operator overloading or not, but Java does not. Another reason could be that one point of arrays is to make the size immutable. So, perhaps there'd be no point in pretending to simulate an expandable array when really a new array would just be created anyway. Least that's why I'd think so. Not 100% sure though.
21st Jul 2017, 4:37 PM
Rrestoring faith
Rrestoring faith - avatar