Readit News logoReadit News
a_w commented on Keep if clauses side-effect free   teamten.com/lawrence/prog... · Posted by u/a_w
a_w · 4 months ago
I do this often:

```ruby

if (user = User.find_by(email: 'abc@example.com'))

  user.update(status: 'active')
end

```

Is it better to do this instead?

```ruby

user = User.find_by(email: 'abc@example.com')

user.update(status: 'active') if user.present?

```

u/a_w

KarmaCake day2284September 30, 2011View Original