General

Profile

lpogic (Łukasz Pomietło)

  • Login: lpogic
  • Registered on: 08/10/2023
  • Last sign in: 07/20/2025

Issues

open closed Total
Assigned issues 0 0 0
Reported issues 0 2 2

Activity

07/20/2025

10:39 PM Ruby Feature #21515: Add `&return` as sugar for `x=my_calculation; return x if x`
jeremyevans0 (Jeremy Evans) wrote in #note-6:
> Not sure why the local variable declaration would matter, as long as you don't pick one already in use.
Because you have to write the name of the variable twice. And coming up with names c...
lpogic (Łukasz Pomietło)
09:50 AM Ruby Feature #21515: Add `&return` as sugar for `x=my_calculation; return x if x`
The advantage of the proposed syntax is that it does not require an explicit declaration of an auxiliary variable, like here:
```rb
return result if result = my_calculation(input_a, input_b)
```
and here:
```rb
x = my_calculation(i...
lpogic (Łukasz Pomietło)

03/05/2025

09:27 AM Ruby Feature #21157: Comparison operator <>
Such a note in the documentation would certainly be advisable. Could a similar one be added to the `max`, `min` and `minmax` methods? lpogic (Łukasz Pomietło)

02/26/2025

02:40 PM Ruby Feature #21157: Comparison operator <>
nobu (Nobuyoshi Nakada) wrote in #note-4:
> I'm not sure what the last example means, maybe incomparable -> true?
Yes, this is a case where objects are incomparable. I'm not sure if `true` is the most appropriate value, but I don't h...
lpogic (Łukasz Pomietło)
02:02 PM Ruby Feature #21157: Comparison operator <>
P3t3rU5 (Pedro Miranda) wrote in #note-3:
> comparison operator already exists it's `<=>`
> ...
`<=>` is good enough for comparing a single property, e.g. `a.y <=> b.y`. Things get complicated when we want to compare several consecutiv...
lpogic (Łukasz Pomietło)
12:21 PM Ruby Feature #21157: Comparison operator <>
I think that not having to create intermediate arrays and referencing the x coordinate when y is different would be an advantage. lpogic (Łukasz Pomietło)
12:06 PM Ruby Feature #21157 (Feedback): Comparison operator <>
I propose introducing a comparison operator *<>* which would give the following results:
```ruby
1 <> 2 # => -1
2 <> 1 # => 1
1 <> 1 # => false
1 <> "a" # => true
```
With the help of the new operator, complex ordering expressio...
lpogic (Łukasz Pomietło)

12/10/2024

01:28 PM Ruby Feature #20925: Allow boolean operators at beginning of line to continue previous line
+1. Regarding indentation, I once read that a multi-line "if" condition looks better with "then":
```
if request.secret_key_base.present?
&& request.encrypted_signed_cookie_salt.present?
&& request.encrypted_cookie_salt.present...
lpogic (Łukasz Pomietło)

11/29/2024

03:52 PM Ruby Feature #20770: A *new* pipe operator proposal
AlexandreMagro (Alexandre Magro) wrote in #note-47:
> The pipe operator is well-known, but this type of operation with assignment is something I haven’t seen before, and I’m not sure of its precedence. The examples also don’t illustrate...
lpogic (Łukasz Pomietło)

11/12/2024

11:50 AM Ruby Feature #20770: A *new* pipe operator proposal
I wonder if the pipeline operator with assignment wouldn't also be useful in everyday code:
``` ruby
str = "ABC"
str |>= _.reverse
str # => "CBA"
a_simple_json = '{"key":"value"}'
a_simple_json |>= JSON.parse _
a_simple_json #...
lpogic (Łukasz Pomietło)

Also available in: Atom