1,030 reputation
47
bio website
location
age
visits member for 3 years, 4 months
seen 15 hours ago

1d
comment Are there any actual drawbacks to self-referential method chaining?
@Panzercrisis OP's been told to refrain using method chaining due to convenience vs. semantics. Steven's answer basically says "do it anyway" and only consider readability of OP's code by itself, without considering the team's opinion or consistency. What if OP wants to rewrite every existing class in the project so that it suits his taste regarding code readability? That's how I understand the convenience/semantics argument: there should be a "technical" reason to have method chaining (btw, that argument also sounds as if the other person is making up an an excuse for his/her own preferences)
Dec
13
comment Is there a way shortcut type bounds in Scala?
I can't answer because I don't enough Scala, but you might try to define a macro (and/or annotations).
Dec
13
comment Why use arg type `class Object` instead of `Comparable[]`?
@user102008 (1) Why would exceptions not be an appropriate way to detect bad arguments? (2) Exactly, and the rest of my answer address Comparable[] vs Object[].
Dec
12
comment Why use arg type `class Object` instead of `Comparable[]`?
@SJuan76 "More than a copy, you just ...": I am not sure I'am following. My understanding is that there is an array allocation (that arrays grows when using new String[0] initially); then we perform a shallow-copy of the elements: references are copied from one array to the other one. Isn't that right?
Dec
12
comment Why use arg type `class Object` instead of `Comparable[]`?
@SJuan76 Thanks, I edited my answer. What you suggest still requires a copy during execution, right? Do you think it might be possible to write "cast-only" code, so that there is no runtime penalty?
Dec
12
revised Why use arg type `class Object` instead of `Comparable[]`?
added 698 characters in body
Dec
12
answered Using Prolog to implement authorization rules
Dec
12
revised Why use arg type `class Object` instead of `Comparable[]`?
added 274 characters in body
Dec
12
revised Why use arg type `class Object` instead of `Comparable[]`?
added 11 characters in body
Dec
12
comment Why use arg type `class Object` instead of `Comparable[]`?
+1 I didn't think about the Comparator. But note that this is incomplete: with the single-argument sort method, we expect all objects to be Comparable. We could still argue that the signature of that method should use Comparable[].
Dec
12
answered Why use arg type `class Object` instead of `Comparable[]`?
Dec
11
comment Is it possible to use functional paradigm in imperative languages?
"Infix functions": maybe you could also mention closures.
Dec
8
comment Choosing a random integer in a range such that it doesn't equal a particular number
@ReignofError Maybe I should have answered the question faster, I don't know. Thanks anyway.
Dec
8
revised Choosing a random integer in a range such that it doesn't equal a particular number
added 720 characters in body
Dec
7
comment Choosing a random integer in a range such that it doesn't equal a particular number
@MichaelGrünewald The joke went over my head, sorry :-)
Dec
6
comment Choosing a random integer in a range such that it doesn't equal a particular number
@MichaelGrünewald Why? They are constants: (1) The first and second lines are minVal=0, maxVal=N (2) maxVal is supposed to be "usually someContainer.size - 1", which makes 0 a natural value for minVal (3) If minVal and maxVal are not fixed, why aren't they passed as function argument? (4) OP's own algorithm involves a modulo operation and doesn't even work if the interval does not start with 0 (!). Of course one can provide a more generic case (replace 0 with minVal and 1 with minVal+1), but I'm here to answer the question, as originally asked. KISS.
Dec
6
comment Choosing a random integer in a range such that it doesn't equal a particular number
@MichaelGrünewald minVal = 0? This is as specified by the question; also, ratchet freak's answer starts with that exact assignment. I just inlined it.
Dec
6
comment Choosing a random integer in a range such that it doesn't equal a particular number
@MichaelGrünewald And why not my answer instead ;-) ? Isn't it equally uniform?
Dec
6
revised Choosing a random integer in a range such that it doesn't equal a particular number
added 1 character in body
Dec
6
revised Choosing a random integer in a range such that it doesn't equal a particular number
added 105 characters in body