<Arsen>
o/ I have a Foo.new(x) and I'd like to skip the new and return nil if x is nil
<Arsen>
is there an idiomatic way to do so?
constxqt has joined #ruby
<wnd>
Not sure what you're after, nor can I tell what's idiomatic, but. I probably wouldn't write it like this, but /if/ wanted to look clever, I might have y = x && Foo.new(x)
<wnd>
"y = Foo.new(x) if x" is probably closer to what you're after
<weaksauc_>
coming from c the first one looks more normal than the second one but that's probably just me
constxqt has quit [Ping timeout: 246 seconds]
<Arsen>
weaksauc_: note that there it's not being used as a condition :P
<Arsen>
wnd: the latter seems reasonable to me, thanks
* Arsen
for some reason only thought of guards
constxqt has joined #ruby
<weaksauc_>
something about accessing variables that are conditionally assigned like that rubs me wrong
<weaksauc_>
y = something && something else feels better to me
<weaksauc_>
since it's always going to get "something" and is always going to be defined
<weaksauc_>
i know you can do it but it feels wrong
constxqt has quit [Ping timeout: 255 seconds]
<havenwood>
return unless x
<havenwood>
Unless the method goes on.
xlymian has quit [Ping timeout: 255 seconds]
caedmon has joined #ruby
caedmon has quit [Ping timeout: 246 seconds]
caedmon has joined #ruby
jess has quit [*.net *.split]
jess has joined #ruby
caedmon has quit [Quit: caedmon]
jas-maelstrom has quit [Quit: Leaving]
edr has quit [Quit: Leaving]
<ox1eef_>
Guard approach is most common IME.
jas-maelstrom has joined #ruby
xlymian has joined #ruby
deadmarshal_ has quit [Server closed connection]
deadmarshal_ has joined #ruby
clemens3 has quit [Server closed connection]
clemens3 has joined #ruby
Aminda has quit [Remote host closed the connection]
Aminda has joined #ruby
grenierm has joined #ruby
Vonter has quit [Ping timeout: 258 seconds]
Vonter has joined #ruby
donofrio has quit [Remote host closed the connection]
Aminda has quit [Remote host closed the connection]
donofrio has joined #ruby
Aminda has joined #ruby
schne1der has joined #ruby
tomtmym has joined #ruby
tomtmym has quit [Changing host]
tomtmym has joined #ruby
legahc has quit [Server closed connection]
legahc has joined #ruby
Vonter has quit [Ping timeout: 246 seconds]
Vonter has joined #ruby
leftylink has quit [Server closed connection]
leftylink has joined #ruby
grenierm has quit [Ping timeout: 250 seconds]
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
_ht has joined #ruby
MomosOrDeath5 has joined #ruby
MomosOrDeath has quit [Ping timeout: 255 seconds]
MomosOrDeath5 is now known as MomosOrDeath
mattf has quit [Server closed connection]
mattf has joined #ruby
Vonter has quit [Ping timeout: 255 seconds]
teclator has quit [Ping timeout: 258 seconds]
Vonter has joined #ruby
Vonter has quit [Ping timeout: 260 seconds]
Vonter has joined #ruby
reset has quit [Quit: reset]
ollysmith has quit [Quit: ZNC 1.8.2+deb3.1 - https://znc.in]
ollysmith has joined #ruby
Aminda has quit [Remote host closed the connection]
Aminda has joined #ruby
schne1der has quit [Quit: schne1der]
schne1der has joined #ruby
gr33n7007h has quit [Ping timeout: 246 seconds]
gr33n7007h has joined #ruby
Artea has quit [Server closed connection]
Artea has joined #ruby
sarna has quit [Ping timeout: 255 seconds]
sts has quit [Server closed connection]
sts has joined #ruby
sarna has joined #ruby
xlymian has quit [Ping timeout: 255 seconds]
TrillionEuroNote has quit [Server closed connection]
TrillionEuroNote has joined #ruby
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
xlymian has joined #ruby
constxqt has joined #ruby
Linux_Kerio has joined #ruby
Thanzex has quit [Ping timeout: 264 seconds]
raz3time has joined #ruby
Guest26nakilon has joined #ruby
<Guest26nakilon>
why do I get "gem install smarter_csv" -> Gem::RemoteFetcher::FetchError bad response Forbidden 403