donofrio has quit [Remote host closed the connection]
donofrio has joined #ruby
Al2O3 has quit [Quit: Good mourning, good after nun, g'nite, and goober evenings.]
donofrio__ has quit [Ping timeout: 268 seconds]
jaredce has joined #ruby
Exa has quit [Quit: see ya!]
user71 has joined #ruby
Exa has joined #ruby
user71 has quit [Quit: Leaving]
cappy has joined #ruby
user71 has joined #ruby
dipnlik has quit [Ping timeout: 240 seconds]
user71 has quit [Quit: Leaving]
cappy has quit [Quit: Leaving]
dipnlik has joined #ruby
srbaker has quit [Ping timeout: 252 seconds]
dipnlik has quit [Ping timeout: 268 seconds]
dipnlik has joined #ruby
user71 has joined #ruby
gaussianblue has joined #ruby
graywolf has joined #ruby
jaredce has quit [Ping timeout: 264 seconds]
graywolf has quit [Quit: WeeChat 4.3.0]
dipnlik has quit [Remote host closed the connection]
dipnlik has joined #ruby
dipnlik has quit [Changing host]
dipnlik has joined #ruby
crespire has joined #ruby
crespire1 has quit [Ping timeout: 264 seconds]
TomyWork has quit [Remote host closed the connection]
xkoncek has joined #ruby
<xkoncek>
is there anything like lazy string interpolation in Ruby?
jaredce has joined #ruby
jaredce has quit [Ping timeout: 268 seconds]
<konsolebox>
xkoncek: Don't know but another strategy to prevent interpolating everything at once is to also receive an optional composer block. I just wonder if Ruby has optimized that part already so procs don't have to be repeatedly compiled.
<konsolebox>
xkoncek: It's helpful when passing a message to a logger function that could be disabled if function level is lower (or higher depending on the strategy) than the current logging level.
<xkoncek>
maybe i'll go with the good ol' % substitution
<konsolebox>
xkoncek: As an example, I could have log.debug{ "Exception received: #{ex.class.to_s}: #{ex.message}\nBacktrace: #{ex.backtrace.join("\n\t")}" }
<konsolebox>
xkoncek: How does that make it lazy?
<xkoncek>
what does the {} do in your case?
<konsolebox>
xkoncek: That's a block.
<konsolebox>
xkoncek: If debugging mode is enabled the proc block is called and the message gets composed. No composing happens if debugging is enabled since the block won't be called.
<konsolebox>
xkoncek: However, if I call log.debug with a message parameter instead, the string is always composed.
<konsolebox>
xkoncek: So it's not "lazy"
<xkoncek>
so in my case, i did not exactly meant lazy, i meant deferred
<kjetilho>
it's the same
<konsolebox>
Why do you seek deferred?
<kjetilho>
or what do you mean by deferred? it will not be evaluated before the value is needed.
<kjetilho>
you want deferred *function* calls, not strings?
<xkoncek>
the function call creates an object, and the actual substitution would happen later
<konsolebox>
xkoncek: Substitution always happens when evaluated. Don't compose anything if keep the objects the way they are if you want to keep the composition of the string to be delayed. You can also utilize the strategy I mentioned above.
donofrio has quit [Quit: Leaving]
donofrio_ has joined #ruby
donofrio_ has quit [Remote host closed the connection]