Ruby has its faults...
-
... but it does have some interesting features, like performing arithmetic on arrays (Aka Lists). If you don't know what I am talking about (Psuedocode):
List l = [ "item1", "item2", "item3", "item4" ]
List l2 = l - "item1" # l2 is [ "item2" , "item3", "item4" ]
List l3 = l + "item5" # l3 is [ "item1" , "item2", "item3", "item4", "item5" ]You can also add / subtract other arrays. I decided to replicate this in C# with a custom list class (it inherits from List<T> and adds the operators). Anyone want the code?
What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???
-
... but it does have some interesting features, like performing arithmetic on arrays (Aka Lists). If you don't know what I am talking about (Psuedocode):
List l = [ "item1", "item2", "item3", "item4" ]
List l2 = l - "item1" # l2 is [ "item2" , "item3", "item4" ]
List l3 = l + "item5" # l3 is [ "item1" , "item2", "item3", "item4", "item5" ]You can also add / subtract other arrays. I decided to replicate this in C# with a custom list class (it inherits from List<T> and adds the operators). Anyone want the code?
What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???
Did you replicate the immutability, or do your operators mutate the list?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
... but it does have some interesting features, like performing arithmetic on arrays (Aka Lists). If you don't know what I am talking about (Psuedocode):
List l = [ "item1", "item2", "item3", "item4" ]
List l2 = l - "item1" # l2 is [ "item2" , "item3", "item4" ]
List l3 = l + "item5" # l3 is [ "item1" , "item2", "item3", "item4", "item5" ]You can also add / subtract other arrays. I decided to replicate this in C# with a custom list class (it inherits from List<T> and adds the operators). Anyone want the code?
What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???
IMO, arithmetic operator overloading is evil, and I see no reason to replace .NET's
Remove
,RemoveAt
,Add
,InsertAt
andAddRange
methods. Of course, the duck-typed advocates love this sort of crap because you can have a function that takes a string, an array, a number, whatever, and "+" will do whatever the interpreter deems appropriate for the types. I will never be comfortable with that kind of madness. MarcLatest Article - Merkle Trees Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
Did you replicate the immutability, or do your operators mutate the list?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I am going to do a rework on it a bit to make it immutable (creating a new list each time).
What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???
-
I am going to do a rework on it a bit to make it immutable (creating a new list each time).
What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???
You might want to look at the Immutable Collections[^] package, rather than building on the existing mutable collections. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
IMO, arithmetic operator overloading is evil, and I see no reason to replace .NET's
Remove
,RemoveAt
,Add
,InsertAt
andAddRange
methods. Of course, the duck-typed advocates love this sort of crap because you can have a function that takes a string, an array, a number, whatever, and "+" will do whatever the interpreter deems appropriate for the types. I will never be comfortable with that kind of madness. MarcLatest Article - Merkle Trees Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
If it walks like a duck, and quacks like a duck, it’s probably gonna throw exceptions at runtime.
GeoGame for Windows Phone | The Lounge Explained In 5 Minutes
-
You might want to look at the Immutable Collections[^] package, rather than building on the existing mutable collections. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I'll look at that. I may end up removing the class instead.
What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???
-
IMO, arithmetic operator overloading is evil, and I see no reason to replace .NET's
Remove
,RemoveAt
,Add
,InsertAt
andAddRange
methods. Of course, the duck-typed advocates love this sort of crap because you can have a function that takes a string, an array, a number, whatever, and "+" will do whatever the interpreter deems appropriate for the types. I will never be comfortable with that kind of madness. MarcLatest Article - Merkle Trees Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
Marc Clifton wrote:
arithmetic operator overloading
Aids in abstracting bugs, something which code maintainers really appreciate.
Peter Wasser "The whole problem with the world is that fools and fanatics are always so certain of themselves, and wiser people so full of doubts." - Bertrand Russell