General

Profile

Alexander.Senko (Alexander Senko)

  • Login: Alexander.Senko
  • Registered on: 12/10/2023
  • Last sign in: 07/23/2025

Issues

open closed Total
Assigned issues 0 0 0
Reported issues 0 1 1

Activity

06/15/2025

12:02 AM Ruby Feature #21435: Kernel#then_try as a conditional #then
`optional` -> `then_try` Alexander.Senko (Alexander Senko)

06/12/2025

06:44 AM Ruby Feature #21435: Kernel#then_try as a conditional #then
@zverok, what do you think about it? May `#then` get a conditional counterpart? Alexander.Senko (Alexander Senko)

06/11/2025

01:12 PM Ruby Feature #21435: Kernel#then_try as a conditional #then
mame (Yusuke Endoh) wrote in #note-5:
> In terms of cognitive complexity, I find it much easier to understand when the logic is written out explicitly, even if it's more verbose, like this:
> ...
Those who prefer iterative logic over met...
Alexander.Senko (Alexander Senko)

06/10/2025

08:33 PM Ruby Feature #21435: Kernel#then_try as a conditional #then
matheusrich (Matheus Richard) wrote in #note-3:
> I'm sorry, I don't understand the use case, nor how it DRY things up.
> ...
The idea is a) to **reduce cognitive complexity** by removing one trivial branch of `if`/`else` statement or ...
Alexander.Senko (Alexander Senko)
02:39 PM Ruby Feature #21435: Kernel#then_try as a conditional #then
nobu (Nobuyoshi Nakada) wrote in #note-1:
> Regarding `respond_to?`, IIRC, isn't ActiveSupport's `try` based on it?
Yes, it would be even simpler with Rails:
```ruby
@record = Record.find(record_id)
.optional { it.try :decorate ...
Alexander.Senko (Alexander Senko)
07:30 AM Ruby Feature #21435 (Rejected): Kernel#then_try as a conditional #then
## What
When chaining, I need sometimes to apply some changes conditionally, like this:
```ruby
@record = Record.find(record_id)
.then { it.respond_to?(:decorate) ? it.decorate : it }
```
It would be great to DRY it a bit:
`...
Alexander.Senko (Alexander Senko)

Also available in: Atom