<clorisu>
sonne: I already checked that on the docs, it's too succint for me to comprehend clearly. I'm just beginning to learn programming
roshanavand has joined #ruby
<sonne>
clorisu: simply stated: x.times do y end <-- does action y, x times. i don't think it gets simpler than that.. 123.times do puts 'hello' end, prints 'hello' 123 times
<dminuoso>
clorisu: Frequently it's best to simply learn by repetition. Try it out, and develop an intuition.
<clorisu>
sonne: i understand that loop. sorry I shouldve clarified. What i'm moreso confused about is the variable that it takes in that doc. eg `5.times do {|thisvar| puts thisvar end}` how does that variable work?
<dminuoso>
clorisu: Think of a do-block as a function that is passed to a method as an extra argument.
<dminuoso>
clorisu: Block variables are arguments of that function.
<dminuoso>
clorisu: So you might think of this as: x.times(->(n) { puts n; })
xall has quit [Quit: xall]
<dminuoso>
clorisu: The meaning of `n` here depends on whatever the method :times choses to call that function with.
<dminuoso>
For the method Integer#times, it happens to do a kind of "for i in 0..n", and call that block with i for each iteration.
aupadhye has joined #ruby
Burgestrand has quit [Quit: Closing time!]
kevinsjoberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dminuoso>
clorisu: this is the same thing really :)
comet23 has joined #ruby
comet23 has left #ruby [#ruby]
<dminuoso>
From that it should be obvious that you could call this `nTimes(10, ->(n) { puts n})`
<dminuoso>
10.times { |n| puts n }
<dminuoso>
Is no different
<dminuoso>
(The subtle differences are nothing to worry about for now)
mikecmpbll has joined #ruby
<dminuoso>
It just looks syntactically different. With `do; end` blocks its not as immediately obvious that you are actually passing a *function* to a method. `obj.method do |abc| ... end` is semantically equivalent to `obj.method(->(abc) { ...})`
<dminuoso>
The do-block is captured as a function, passed to the method and the method can then "call it" as a sort of callback whenver it wants
sameerynho has quit [Ping timeout: 264 seconds]
comet23 has joined #ruby
Bish has joined #ruby
<Bish>
i would like to use authentication with mechanize in the form of http://a:b@c.de
<Bish>
how does one do thath
dbz has joined #ruby
cfjk has quit [Read error: Connection reset by peer]
al2o3-cr has quit [Quit: WeeChat 2.2]
gr33n7007h has joined #ruby
dbz has quit [Ping timeout: 272 seconds]
gr33n7007h is now known as al2o3-cr
RedNifre has joined #ruby
Freshnuts has quit [Quit: Leaving]
RedNifre_ has quit [Ping timeout: 268 seconds]
clemens3 has quit [Remote host closed the connection]
clemens3 has joined #ruby
phoo1234567 has quit [Quit: Gotta go]
ur5us has joined #ruby
CrazyEddy has joined #ruby
vonfry has joined #ruby
graphene has quit [Remote host closed the connection]
graphene has joined #ruby
dbz has joined #ruby
jamesaxl has joined #ruby
vonfry has quit [Ping timeout: 264 seconds]
ur5us has quit [Remote host closed the connection]
Burgestrand has joined #ruby
ur5us has joined #ruby
dbz has quit [Ping timeout: 244 seconds]
ur5us has quit [Ping timeout: 252 seconds]
nowhere_man has joined #ruby
sameerynho has joined #ruby
comet23 has quit [K-Lined]
sameerynho has quit [Ping timeout: 264 seconds]
kevinsjoberg has joined #ruby
savolla has joined #ruby
aufi has joined #ruby
despai has quit [Quit: ...]
despai has joined #ruby
AJA4350 has joined #ruby
fmcgeough has joined #ruby
fmcgeough has quit [Client Quit]
<kke>
"bundle install --deployment" with a gemfile that just says "gemspec" seems to install all gems listed in "spec.add_development_dependency"?
mike11 has quit [Read error: Connection reset by peer]
<tbuehlmann>
kke: seems about right, what's the problem?
<kke>
tbuehlmann: i would assume --deployment does not include development dependencies
<wyoung>
I am learning Ruby from python. does Ruby usr similar patterns? like pythons **{'kwarg1': 1, 'kwarg2': 2} for argument passing to a function or method?
<wyoung>
also when are default function / method parameters? once or at class initiating time?
savolla has quit [Ping timeout: 276 seconds]
<tbuehlmann>
ruby also has keyword arguments, yes
<tbuehlmann>
I don't understand the second quesion, can you elaborate?
<dminuoso>
And doing this with runtime abstractions is nonsense
<dminuoso>
Or rather.. simulating this with hashes and things.
GodFather__ has quit [Ping timeout: 244 seconds]
bijan_ has joined #ruby
<ccooke>
you could do this quite nicely by running all the tests as something like: %w{ key1 key2 key3 }.each { |k| raise "#{k} is not set" unless ENV.include? k }
Inline has joined #ruby
<ccooke>
but that's not specifically answering your question
<dminuoso>
Yeah no I want monadic code.
<ccooke>
Hmm. So what would your ideal code look more like?
bijan__ has joined #ruby
bijan_ has quit [Read error: Connection reset by peer]
bmurt has quit [Read error: Connection reset by peer]
bmurt has joined #ruby
bijan__ has quit [Ping timeout: 252 seconds]
despai has quit [Quit: ...]
<dminuoso>
Monadic.
<dminuoso>
I dont know Ruby very well so..
nopolitica has quit [Ping timeout: 252 seconds]
sticaz has quit [Quit: BELLA LI]
bijan__ has joined #ruby
bijan__ has quit [Read error: Connection reset by peer]
bijan_ has quit [Read error: Connection reset by peer]
graphene has quit [Remote host closed the connection]
graphene has joined #ruby
bijan_ has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bijan_ has quit [Remote host closed the connection]
jcarl43 has joined #ruby
clemens3 has quit [Ping timeout: 276 seconds]
bijan_ has joined #ruby
nowhere_man has joined #ruby
aufi has quit [Quit: Leaving]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bijan_ has quit [Ping timeout: 252 seconds]
nopolitica has joined #ruby
bijan_ has joined #ruby
sameerynho has joined #ruby
bijan_ has quit [Ping timeout: 252 seconds]
despai has joined #ruby
bijan_ has joined #ruby
lxsameer has quit [Ping timeout: 244 seconds]
DTZUZO has quit [Ping timeout: 264 seconds]
bijan_ has quit [Ping timeout: 252 seconds]
yohji has quit [Remote host closed the connection]
dbugger_ has joined #ruby
darkhanb has joined #ruby
bijan_ has joined #ruby
gtramontina has quit [Remote host closed the connection]
jp has quit [Ping timeout: 244 seconds]
Dbugger has quit [Ping timeout: 276 seconds]
jp has joined #ruby
bijan_ has quit [Read error: Connection reset by peer]
dviola has joined #ruby
bmurt has joined #ruby
doubledup has joined #ruby
IanMalcolm has joined #ruby
cthulchu_ has joined #ruby
lxsameer has joined #ruby
despai has quit [Quit: ...]
bijan_ has joined #ruby
lxsameer has quit [Ping timeout: 268 seconds]
cthu| has joined #ruby
polishdub has joined #ruby
IanMalcolm has quit [Remote host closed the connection]
orbyt_ has joined #ruby
ramfjord has joined #ruby
ferhaty has joined #ruby
IanMalcolm has joined #ruby
dbz has joined #ruby
cthulchu_ has quit [Ping timeout: 276 seconds]
cthulchu_ has joined #ruby
bsamorim has joined #ruby
cthu| has quit [Ping timeout: 276 seconds]
Eiam has joined #ruby
dellavg_ has quit [Ping timeout: 252 seconds]
<bsamorim>
Is there anyway to explicitly decrease a variable's reference count by 1, so that it can be garbage collected before its scope dies?
ramfjord has quit [Ping timeout: 268 seconds]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
dbz has quit [Ping timeout: 264 seconds]
bsamorim has quit [Read error: Connection reset by peer]
bsamorim has joined #ruby
gtramontina has joined #ruby
r29v has joined #ruby
dellavg_ has joined #ruby
gtramontina has quit [Ping timeout: 268 seconds]
theRoUS has quit [Read error: Connection reset by peer]
<al2o3-cr>
bsamorim: you'll probably want to check out weakref from the stdlib.
aupadhye has joined #ruby
dbz has joined #ruby
<bsamorim>
al2o3-cr: Thanks, that seems to do the trick. Just wondering, tho: Do you know if there's any reason for them not to expose a direct deletion method?
<al2o3-cr>
bsamorim: not sure tbh.
<bsamorim>
I mean, by the reference documentation, WeakRef's main functionality seems to be letting objects being garbage-collected
<bsamorim>
al2o3-cr: OK, thanks!
<al2o3-cr>
bsamorim: yw.
s2013 has joined #ruby
IanMalcolm has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<bsamorim>
One more GC question: If I issue a "[1] * 100000000" expression in irb, after its completion, the memory doesn't seem to be freed.
<bsamorim>
I thought the repl automatically stored a reference to the last evaluated expression
<bsamorim>
But, if I eval the expression "1", the allocated memory is still there!
<bsamorim>
Moreover, if I issue a "[2] * 100000000" expression afterwards, the allocated amount does not change
<bsamorim>
Does anyone know what's going on?
al2o3-cr has quit [Quit: WeeChat 2.2]
aupadhye has quit [Quit: Leaving]
gr33n7007h has joined #ruby
gr33n7007h is now known as al2o3-cr
eckhardt has joined #ruby
dellavg_ has quit [Ping timeout: 264 seconds]
thejs has quit [Ping timeout: 272 seconds]
beowuff has joined #ruby
bmurt has quit [Read error: Connection reset by peer]
gnufied has quit [Quit: Leaving]
bmurt has joined #ruby
thejs has joined #ruby
Rootsudo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bmurt has quit [Read error: Connection reset by peer]
kaleido has quit [Remote host closed the connection]
bmurt has joined #ruby
r29v has quit [Quit: r29v]
dbugger_ has quit [Ping timeout: 276 seconds]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
bak1an has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bak1an has joined #ruby
bak1an has quit [Client Quit]
dinfuehr has quit [Ping timeout: 264 seconds]
dinfuehr has joined #ruby
Zaab1t has quit [Quit: Zaab1t]
orbyt_ has joined #ruby
jane_booty_doe has quit [Quit: Leaving]
r29v has joined #ruby
ramfjord has quit [Ping timeout: 252 seconds]
ramfjord has joined #ruby
fmcgeough has quit [Quit: fmcgeough]
ramfjord has quit [Ping timeout: 268 seconds]
GodFather__ has joined #ruby
ramfjord has joined #ruby
akaiiro has quit [Remote host closed the connection]
Freeaqingme has joined #ruby
<Freeaqingme>
Hi folks, I'm playing around with some networking stuff. Am looking to get the first usable ip in a subnet. e.g., I've got 10.11.12.150/25, and I expect it to return 10.11.12.129. Basically, what I want to do is IPAddr.new('10.11.12.150/25')+1, but the + operator isn't (albeit understandably) implemented on the IPAddr object.
<Freeaqingme>
any ideas how to implement this?
<Freeaqingme>
oh lol, I figured I'd ask after 30 mins of trying. But of course right after asking you find the answer...
<Freeaqingme>
This seems to do the trick for both ipv4 and ipv6: irb(main):016:0> IPAddr.new('10.11.12.150/25')&IPAddr.new('0.0.0.1')
SeepingN has quit [Quit: The system is going down for reboot NOW!]
<al2o3-cr>
[0,0,0,1].pack('C4').unpack1('N') == 1
Freeaqingme has joined #ruby
<al2o3-cr>
or even #succ
<baweaver>
al2o3-cr: Where does one learn all this packery?
mudphone has joined #ruby
<al2o3-cr>
the docs mostly.
<baweaver>
I C....
mondz has joined #ruby
chongtxtx has joined #ruby
r29v has quit [Quit: r29v]
mondz has quit [Remote host closed the connection]
varesa_ is now known as varesa
<al2o3-cr>
4841434b544845504c414e4554 baweaver pack this ;)
<baweaver>
Are you trying to hex me?
<al2o3-cr>
hehe ;)
Puffball has quit [Read error: Connection reset by peer]
dbz has joined #ruby
Puffball has joined #ruby
code_zombie has joined #ruby
sameerynho has quit [Ping timeout: 268 seconds]
lxsameer has joined #ruby
nfk has joined #ruby
<nfk>
could it be that tk 8.6 does not even work with ruby?
RedNifre_ has quit [Quit: kwit]
kapil___ has quit [Quit: Connection closed for inactivity]
reber has quit [Remote host closed the connection]
Azure has joined #ruby
lxsameer has quit [Ping timeout: 252 seconds]
dbz has quit [Remote host closed the connection]
<al2o3-cr>
nfk: i doubt that.
druonysus has joined #ruby
<nfk>
well, i just built ruby with tk aand i don't think it got built; googling yields mixed results, some imply it works fine, other sources say 8.5 is the only one that works which is why i'm asking in a channel where someone hopefully knows for sure
<nfk>
s/only/newest/
xtsee has joined #ruby
<al2o3-cr>
nfk: it definitely does, i just tested tk 8.6.3
<al2o3-cr>
8.6.8 infact.
Azure has quit [Ping timeout: 268 seconds]
Azure|dc has joined #ruby
<al2o3-cr>
nfk: what have you tried?
desperek has quit [Quit: xoxo]
heinrich5991 has quit [Ping timeout: 264 seconds]
Rootsudo has joined #ruby
ur5us has joined #ruby
<nfk>
well, i just told portage to build ruby with tk USE flag
<nfk>
which it did, except require 'tk' does not work and doing examination of installed files, there's nothing about tk
<nfk>
which to me tells that most likely it silently failed during configure step of compilation
heinrich5991 has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<al2o3-cr>
nfk: tk is a gem now; so gem install tk.
augcesar has quit [Quit: Connection closed for inactivity]
gix has joined #ruby
bijan_ has quit [Ping timeout: 252 seconds]
<nfk>
man, i can't believe i haven't written ruby in like a year or two but i can still do stuff like passing a block to constructor intuitively, and it worked
bijan_ has joined #ruby
sticaz has quit [Ping timeout: 272 seconds]
<clorisu>
baweaver: is it more aptly called a branch?
bijan_ has quit [Ping timeout: 252 seconds]
<baweaver>
yep
<clorisu>
thanks
jane_booty_doe has joined #ruby
clorisu has quit [Quit: Leaving]
bijan_ has joined #ruby
bijan_ has quit [Ping timeout: 252 seconds]
r29v has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bijan_ has joined #ruby
polishdub has quit [Quit: leaving]
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sdegutis has joined #ruby
bijan_ has quit [Ping timeout: 252 seconds]
<sdegutis>
Hi all.
sticaz has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
graphene has quit [Read error: Connection reset by peer]
<sdegutis>
How's it going?
eckhardt has joined #ruby
graphene has joined #ruby
bijan_ has joined #ruby
siery has joined #ruby
beowuff has quit [Remote host closed the connection]
bijan_ has quit [Ping timeout: 252 seconds]
r29v has quit [Quit: r29v]
lxsameer has joined #ruby
bijan_ has joined #ruby
lxsameer has quit [Ping timeout: 268 seconds]
<nfk>
pretty good, i just calculated that it's cheaper to buy strong spirits at bargain prices than even the cheapest beer on discount, which i was suspecting for a while but now i know for sure thanks to irb and some math
<bougyman>
isn't wine the cheapest?
akaiiro has joined #ruby
Puffball has joined #ruby
<sdegutis>
nfk: lol
<nfk>
hmm.... supermarket estate bottled on average - not even worth computing; cheapest of cheap... let me run the numbers
bijan_ has quit [Ping timeout: 252 seconds]
r29v has joined #ruby
nopolitica has quit [Read error: Connection reset by peer]
nopolitica has joined #ruby
bauruine has quit [Ping timeout: 264 seconds]
sonOfRa has quit [Quit: Bye!]
sonOfRa has joined #ruby
<nfk>
bougyman, nope, at least among the bottled wines, even the trashiest would be like 60+% more expensive than spirits that i can get legally
<bougyman>
I found a few charts on this.
<bougyman>
a cheap shiraz competes well with the cheapest vodkas.
<bougyman>
pretty much the same.
ccooke has quit [Ping timeout: 268 seconds]
<nfk>
then again, our 15 and sometimes less euros per liter for strong spirits is probably on the very cheap end for an ostensibly developed nation
<bougyman>
I can get a 1.75L bottle of cheap vodka for around $10 USD
[Butch] has quit [Read error: Connection reset by peer]
Puffball_ has joined #ruby
<bougyman>
but I get a 750ml bottle of cheap shiraz for $2.99
cthulchu has joined #ruby
<nfk>
bougyman, i don't think those are legal here, that having been said, vodka that's priced that low is such trash that you might as well go and drink straight methanol
<bougyman>
nfk: not arguing.
bijan_ has joined #ruby
<bougyman>
But I don't know why cheap wine would be illegal there...
<nfk>
i have never seen 1.75L vodka bottles
<bougyman>
Haha.
<nfk>
1L is the largest you can commonly get and, if they have good price, usually the price tag is all that remains
<sdegutis>
Were any of you here maybe 8 years ago?
<nfk>
not rulling it out, why?
<nfk>
actually... unlikely
<nfk>
that many years ago i might not have even heard of ruby
bijan_ has quit [Ping timeout: 252 seconds]
<nfk>
bougyman, at least now i know why 'murica is considered a nation of drunkards ;D
cgfbee has joined #ruby
<siery>
Vodka shold be the cheepest, potetos cost nothing
<nfk>
you can poison yourself with vodka for less than a cost of a good meal over the pond
<siery>
better start thinkng about mruby vodka destilator
bauruine has joined #ruby
<nfk>
siery, arguably most alcohols cost very little, after all, it's possible to produce it as a car fuel, and there even €1/L is already a hefty price
LiftLeft has quit [Ping timeout: 264 seconds]
<siery>
nfk, Nah, I dont like vodka even due my Polish roots it is probably not likly to say
gtramontina has joined #ruby
<nfk>
i know, it's kinda bland, i prefer whiskey and brandy myself
bijan_ has joined #ruby
<sdegutis>
nfk: ok nvm
<nfk>
bougyman, so, did you order your 9 dollar vodka?
thejs has quit [Ping timeout: 252 seconds]
<nfk>
btw, that nickname ending, LT?
<siery>
Leave us a raport when man C:
ramfjord has quit [Ping timeout: 272 seconds]
bijan_ has quit [Ping timeout: 252 seconds]
gtramontina has quit [Ping timeout: 252 seconds]
ramfjord has joined #ruby
gregf_ has quit [Ping timeout: 252 seconds]
r29v has quit [Quit: r29v]
orbyt_ has joined #ruby
paraxial has quit [Ping timeout: 252 seconds]
ramfjord has quit [Ping timeout: 244 seconds]
ramfjord has joined #ruby
bijan_ has joined #ruby
roshanavand has quit [Ping timeout: 264 seconds]
LiftLeft has joined #ruby
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
paraxial has joined #ruby
ramfjord has quit [Ping timeout: 244 seconds]
eckhardt has joined #ruby
bijan_ has quit [Ping timeout: 252 seconds]
ramfjord has joined #ruby
eckhardt has quit [Client Quit]
bijan_ has joined #ruby
gtramontina has joined #ruby
thejs has joined #ruby
gtramontina has quit [Remote host closed the connection]
arescorpio has joined #ruby
gtramontina has joined #ruby
gtramontina has quit [Remote host closed the connection]
bijan_ has quit [Ping timeout: 252 seconds]
tdy has quit [Ping timeout: 268 seconds]
roshanavand has joined #ruby
thejs has quit [Remote host closed the connection]