baweaver changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.5.1, 2.4.4, 2.3.7, 2.6.0-preview2: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.de/ and select ruby as the language | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first!
za1b1tsu has quit [Ping timeout: 245 seconds]
improv42 has joined #ruby
Puffball has quit [Remote host closed the connection]
ansraliant has quit [Ping timeout: 252 seconds]
ansraliant has joined #ruby
improv42 has quit [Remote host closed the connection]
c0ncealed3 has quit [Remote host closed the connection]
c0ncealed3 has joined #ruby
bmurt has joined #ruby
asphyxia has joined #ruby
moei has quit [Read error: Connection reset by peer]
moei has joined #ruby
orbyt_ has joined #ruby
dbz has joined #ruby
asphyxia has quit [Ping timeout: 268 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dbz has quit [Ping timeout: 260 seconds]
dbz has joined #ruby
dbz has quit [Remote host closed the connection]
uplime has joined #ruby
asphyxia has joined #ruby
SeepingN has quit [Ping timeout: 252 seconds]
exchgr` has quit [Ping timeout: 240 seconds]
marahin has quit [Ping timeout: 246 seconds]
lyr has quit [Quit: Ping timeout (120 seconds)]
marahin has joined #ruby
scientes has quit [Remote host closed the connection]
lyr has joined #ruby
TheBrayn has quit [Ping timeout: 246 seconds]
exchgr has joined #ruby
TheBrayn has joined #ruby
tdy has quit [Ping timeout: 244 seconds]
vikaton has quit [Quit: Connection closed for inactivity]
sarmiena_ has quit [Quit: sarmiena_]
P1RATEZ has joined #ruby
Dimik has joined #ruby
tdy has joined #ruby
DTZUZO has quit [Remote host closed the connection]
DTZUZO has joined #ruby
za1b1tsu has joined #ruby
za1b1tsu has quit [Ping timeout: 244 seconds]
cagomez has joined #ruby
eckhardt has quit [Quit: Textual IRC Client: www.textualapp.com]
asphyxia has quit [Ping timeout: 246 seconds]
ajsharma has joined #ruby
Francisco has quit [Remote host closed the connection]
Francisco has joined #ruby
herbmillerjr has quit [Quit: Konversation terminated!]
orbyt_ has joined #ruby
roshanavand has quit [Ping timeout: 252 seconds]
Blaguvest has quit []
AJA4350 has quit [Quit: AJA4350]
P1RATEZ has quit []
mroutis has joined #ruby
braincrash has quit [Quit: bye bye]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
braincrash has joined #ruby
podlech has joined #ruby
dellavg_ has joined #ruby
podlech has quit [Client Quit]
orbyt_ has joined #ruby
podlech has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
code_zombie has quit [Quit: Leaving]
RougeR has quit [Ping timeout: 252 seconds]
jasmith has quit [Quit: Leaving]
hahuang6- is now known as hahuang65
arescorpio has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
arescorpio has quit [Remote host closed the connection]
Dimik has quit [Ping timeout: 272 seconds]
cagomez has quit [Remote host closed the connection]
cagomez has joined #ruby
sarmiena_ has joined #ruby
sarmiena_ has quit [Client Quit]
sarmiena_ has joined #ruby
cagomez has quit [Ping timeout: 272 seconds]
<Radar> 2 protips for junior rubyists: 1( attr_reader != attr_accessor (plz learn the difference) 2) keyword arguments were added in Ruby 2.0 (circa end of 2013) and will drastically reduce the code you write in initialize. Please use them.
<Radar> Signed, someone who is reviewing many, many junior Rubyist coding tests.
<Radar> THIRD BONUS PROTIP: Look at the Enumerable module. Gaze into it. Let it envelope you. `find` yourself within it. `select` from it particular methods that will help you. `each_with_object`, etc, etc, etc.
<baweaver> Oh come now Radar, that's just sad, only two enumerable puns? I reject that notion
<Radar> baweaver: Sorry, I was all? out of puns. I didn't have any? more.
<Radar> But now I am reading the documentation to .collect some more. I'll tell you the .first one I come across. p.s. inject is bad okay
<baweaver> I'm sure you'll filter out a few more (bonus for 2.6 syntax :D )
<Radar> each_with_object is much much better
<uplime> what are keyword arguments?
<baweaver> There are cases for reduce
<uplime> oh, foo(bar: baz, bing: bingo) ?
<baweaver> def adds(a:, b:) a + b end
<baweaver> adds(a: 1, b: 2) # => 3
<baweaver> yep
<Radar> ^ The blog post I have linked to about 15 times during these junior code review feedback writeups
<Radar> And blocks support keyword args too
<baweaver> Which is super fun with hashes :D
<baweaver> >> [{ a: 1 }, { b: 2 }].map { |a: 1, b: 2| a + b }
<ruby[bot]> baweaver: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<baweaver> => [3, 3]
<Radar> ruby[bot]: just plz stop
<Radar> ruby[bot]: you're not even trying any more
AKPWD has quit [Quit: じゃね。]
krautcat has quit [Ping timeout: 268 seconds]
ajsharma has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mroutis has quit [Remote host closed the connection]
dellavg_ has quit [Ping timeout: 272 seconds]
Cyrus has quit [Quit: quitting...]
AKPWD has joined #ruby
eckhardt has joined #ruby
Cyrus has joined #ruby
Cyrus has quit [Client Quit]
Cyrus has joined #ruby
shakes has joined #ruby
asphyxia has joined #ruby
shakes has quit [Quit: Leaving]
dbz has joined #ruby
za1b1tsu has joined #ruby
apeiros_ has quit [Remote host closed the connection]
reber has joined #ruby
dbz has quit [Ping timeout: 268 seconds]
_whitelogger has joined #ruby
apeiros_ has joined #ruby
apeiros_ has quit [Remote host closed the connection]
MyMind has joined #ruby
Sembei has quit [Ping timeout: 245 seconds]
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
argoneus has quit [Ping timeout: 252 seconds]
argoneus has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
iAmDecim has quit [Ping timeout: 252 seconds]
edwardthefma has quit [Ping timeout: 252 seconds]
aupadhye has joined #ruby
dbz has joined #ruby
snickers has joined #ruby
TomyLobo has joined #ruby
TomyLobo has quit [Read error: Connection reset by peer]
leafyleong has quit [Ping timeout: 268 seconds]
leafyleong has joined #ruby
stoffus has joined #ruby
nowhereman_ has joined #ruby
phaul has joined #ruby
clemens3 has joined #ruby
eckhardt_ has joined #ruby
yohji has joined #ruby
kreantos has joined #ruby
themsay has joined #ruby
z3uS has quit [Ping timeout: 252 seconds]
kreantos has quit [Remote host closed the connection]
z3uS has joined #ruby
themsay has quit [Ping timeout: 252 seconds]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
agent_white has quit [Quit: leaving]
sarmiena_ has quit [Quit: sarmiena_]
dbz has quit [Remote host closed the connection]
DTZUZO has quit [Ping timeout: 268 seconds]
sonOfRa has left #ruby ["Leaving"]
ellcs has joined #ruby
VladGh has quit [Ping timeout: 252 seconds]
mike11 has joined #ruby
lxsameer has joined #ruby
ellcs has quit [Ping timeout: 276 seconds]
themsay has joined #ruby
Terens has joined #ruby
<Terens> hello
<Terens> how can I initialize my hash here
<Terens> hash[:date] << key.to_s if property[:type] == :date
xfbs has joined #ruby
themsay has quit [Ping timeout: 272 seconds]
<phaul> do you mean hash is a new local var on that line, ie hash did not exist before?
<phaul> Terens: you said initialize, which is why Im asking
weaksauce has quit [Ping timeout: 252 seconds]
venmx has joined #ruby
VladGh has joined #ruby
<phaul> Terens?
MoritaShinobu has quit [Quit: Leaving]
teclator has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
aufi_ has joined #ruby
iAmDecim has joined #ruby
iAmDecim has quit [Client Quit]
za1b1tsu has quit [Ping timeout: 240 seconds]
aufi_ has quit [Ping timeout: 246 seconds]
p0s1x has joined #ruby
p0s1x has quit [Client Quit]
za1b1tsu has joined #ruby
eckhardt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
clemens3 has quit [Remote host closed the connection]
<zenspider> Don't you love it when someone asks a question with seemingly no desire for an answer?
clemens3 has joined #ruby
<phaul> yes, Im not sure what happened there.
_whitelogger has joined #ruby
discopatrick has joined #ruby
MoritaShinobu has joined #ruby
aufi_ has joined #ruby
aufi_ has quit [Ping timeout: 272 seconds]
AJA4350 has joined #ruby
asphyxia has quit [Ping timeout: 252 seconds]
eckhardt has quit [Ping timeout: 252 seconds]
aufi_ has joined #ruby
michael_mbp has quit [Quit: Checkout my channel at http://www.youtube.com/bsodmike]
apeiros_ has joined #ruby
nowhereman_ has quit [Ping timeout: 252 seconds]
apeiros_ has quit [Client Quit]
mike11 has quit [Ping timeout: 252 seconds]
michael_mbp has joined #ruby
aufi_ has quit [Ping timeout: 272 seconds]
MoritaShinobu has quit [Quit: Leaving]
aufi_ has joined #ruby
jacobat has joined #ruby
<jacobat> Is there an easy way to capture keywords args into a hash?
<jacobat> I could change the method signature to use a hash instead of kw args but that's not what I'm looking for
<tbuehlmann> `def foo(**kwargs); kwargs; end` where kwargs will be a hash, do you mean that?
<jacobat> No, I want to maintain a signature like `def foo(a:, b:)` - but in the body of the method I want an easy way to convert it into a hash, or otherwise use a subset of the arguments.
<jacobat> Here's a simple example of what I need: https://gist.github.com/jacobat/ab7b14530e0f1c790e2c79683ba7a404
<jacobat> Just imagine the number of arguments being somewhat bigger
bkxd has quit [Ping timeout: 260 seconds]
<tbuehlmann> I don't think that's easily possible
<jacobat> Alright, thanks :)
aufi_ has quit [Ping timeout: 252 seconds]
estrod has joined #ruby
improv42 has joined #ruby
improv42 has quit [Ping timeout: 260 seconds]
estrod has quit [Quit: Leaving]
emerson has quit [Quit: WeeChat 2.2]
kurko_ has joined #ruby
phaul has quit [Ping timeout: 252 seconds]
znz_jp has quit [Quit: kill -QUIT $$]
znz_jp has joined #ruby
emerson has joined #ruby
dbz has joined #ruby
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Azure has quit [Ping timeout: 244 seconds]
dbz has quit [Ping timeout: 240 seconds]
Azure has joined #ruby
bmurt has joined #ruby
kurko_ has joined #ruby
Francisco has quit [Remote host closed the connection]
Francisco has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
phaul has joined #ruby
bmurt has joined #ruby
nowhereman_ has joined #ruby
bkxd has joined #ruby
beefjoe has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
deathwishdave has joined #ruby
<deathwishdave> afternoon
<deathwishdave> simple one i'm sure, https://gist.github.com/deathwishdave/a80dbada482a3533995d46829174aa6a, why does it output {"A"=>1, "A"=>3} ?
<deathwishdave> why do I have two "A" keys?
snickers has quit [Ping timeout: 250 seconds]
snickers has joined #ruby
<leah2> data[i] = data[j] you want == there
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dmitch has joined #ruby
estrod has joined #ruby
<deathwishdave> leah2 thanks, i did actually have that before, but changed while trying to find the issue
<leah2> and it prints {"A"=>4} here
<deathwishdave> oh
<leah2> and with Hash.new(0) you can always +=1
<deathwishdave> leah2, i get...
<deathwishdave> Daves-MacBook-Pro:RayCastOptimisations Dave$ ruby Optimise.rb
<deathwishdave> {"A"=>1, "A"=>1}
<deathwishdave> Daves-MacBook-Pro:RayCastOptimisations Dave$
<deathwishdave> weird
<leah2> which ruby version?
<deathwishdave> ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
beefjoe has quit [Ping timeout: 252 seconds]
<leah2> quite old. but this always worked oO
<leah2> puts groups.keys.map {|x| x.hash }
snickers has quit [Ping timeout: 240 seconds]
beefjoe has joined #ruby
<deathwishdave> -4025386002249382175
<deathwishdave> Daves-MacBook-Pro:RayCastOptimisations Dave$ ruby Optimise.rb
<deathwishdave> -1911482060860157796
<deathwishdave> Daves-MacBook-Pro:RayCastOptimisations Dave$
<leah2> interesting oO
<deathwishdave> :-)
<deathwishdave> upgrading ruby
<leah2> if you add p "A".hash
Francisco has quit [Read error: Connection reset by peer]
Fr4n has joined #ruby
<deathwishdave> Daves-MacBook-Pro:RayCastOptimisations Dave$ ruby Optimise.rb
<deathwishdave> 1064180750834429922
<deathwishdave> -2843238284506867293
<deathwishdave> Daves-MacBook-Pro:RayCastOptimisations Dave$
bmurt has joined #ruby
<leah2> it should print 3 things then
<deathwishdave> yes
<deathwishdave> leah2 see above
dbz has joined #ruby
<leah2> the values change every run
<deathwishdave> in the csv? no
<leah2> the hashes
<leah2> but two should be the same oO
dbz has quit [Ping timeout: 246 seconds]
moei has quit [Read error: Connection reset by peer]
jidar has quit [Read error: Connection reset by peer]
jidar has joined #ruby
moei has joined #ruby
<phaul> I wonder if 'A' is different from 'A' due to some nonvisible UTF8 or similar tricks...
<leah2> at least from the posted csv file that is not the case
marahin has quit [Ping timeout: 268 seconds]
raulp has quit [Read error: Connection reset by peer]
<deathwishdave> phaul i did consider that
marahin has joined #ruby
<deathwishdave> I rewrote the csv file
<deathwishdave> no copy or paste
uplime has quit [Ping timeout: 272 seconds]
bkxd has joined #ruby
aufi_ has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
SeepingN has joined #ruby
bkxd has joined #ruby
beefjoe has quit [Read error: Connection reset by peer]
aufi_ has quit [Ping timeout: 252 seconds]
bkxd has quit [Read error: Connection reset by peer]
nowhereman_ has quit [Ping timeout: 264 seconds]
estrod has quit [Quit: Leaving]
stoffus has quit [Ping timeout: 260 seconds]
<deathwishdave> leah2 same result with Ruby 2.5.1p57
DTZUZO has joined #ruby
<deathwishdave> leah2 , phaul fixed it!
<phaul> you have to tell us how :)
<deathwishdave> the csv was exported from Excel, i had only been changing it contents.
<deathwishdave> I created a new csv in my editor, and pasted contents in, now works!
<deathwishdave> this was excel for mac
dionysus69 has quit [Quit: ZNC 1.7.1+deb2 - https://znc.in]
dionysus69 has joined #ruby
johnny56 has quit [Ping timeout: 272 seconds]
chouhoulis has joined #ruby
dionysus69 has quit [Quit: ZNC 1.7.1+deb2 - https://znc.in]
dionysus69 has joined #ruby
snickers has joined #ruby
dinfuehr_ has quit [Ping timeout: 244 seconds]
ogres has joined #ruby
dinfuehr has joined #ruby
Rapture has joined #ruby
bkxd has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
bkxd has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
jacobat has quit [Ping timeout: 252 seconds]
phaul is now known as yarr
yarr is now known as rubydoc
nowhereman_ has joined #ruby
rubydoc has quit [Quit: bye]
phaul has joined #ruby
bkxd has joined #ruby
orbyt_ has joined #ruby
aufi_ has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
uplime has joined #ruby
bkxd has joined #ruby
dbz has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
aufi_ has quit [Ping timeout: 252 seconds]
rubydoc has joined #ruby
dbz has quit [Ping timeout: 245 seconds]
<phaul> I've started doing rubydoc ... I have 21 lines of code atm. so he is completely broken
<phaul> &ri Array#count
aupadhye has quit [Ping timeout: 252 seconds]
<phaul> whops there you go. I don't know why he replied twice...
bkxd has joined #ruby
<orbyt_> ?
<phaul> derpy replacement
<orbyt_> &ri Array#first
<orbyt_> Why is the command &ri lol
<phaul> we had a bot for this a while ago. Links the documentation. I am trying to resurect that
<phaul> the old bot used the command &ri iirc
DTZUZO has quit [Ping timeout: 260 seconds]
bkxd has quit [Read error: Connection reset by peer]
rippa has joined #ruby
<orbyt_> phaul Ah, weird
<orbyt_> & is a weird character to trigger commands
<phaul> Feel free to suggest something else. I'll change it
<phaul> just don't collide with rubybot
apeiros_ has joined #ruby
arup_r has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rubydoc has quit [Remote host closed the connection]
raulp has joined #ruby
aufi_ has joined #ruby
GodFather has joined #ruby
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
aufi_ has quit [Ping timeout: 272 seconds]
clemens3 has quit [Ping timeout: 244 seconds]
schneider has joined #ruby
DTZUZO has joined #ruby
arup_r has quit [Ping timeout: 252 seconds]
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lxsameer has quit [Ping timeout: 245 seconds]
jcarl43 has joined #ruby
duderonomy has joined #ruby
truenito has joined #ruby
truenito has quit [Remote host closed the connection]
johnny56 has joined #ruby
duderonomy has quit [Client Quit]
duderonomy has joined #ruby
duderonomy has quit [Client Quit]
dbz has joined #ruby
cthulchu has joined #ruby
dbz has quit [Ping timeout: 268 seconds]
dmitch has quit [Ping timeout: 252 seconds]
bkxd has joined #ruby
evdubs_ has quit [Remote host closed the connection]
phaul has quit [Ping timeout: 244 seconds]
evdubs_ has joined #ruby
* baweaver wanders in
snickers has joined #ruby
yohji has quit [Remote host closed the connection]
darkhanb has joined #ruby
sarmiena_ has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
dbz has joined #ruby
conta1 has joined #ruby
DTZUZO has quit [Ping timeout: 244 seconds]
DTZUZO_ has joined #ruby
bkxd has joined #ruby
uplime has quit [Ping timeout: 268 seconds]
Francisco has joined #ruby
Francisco has quit [Client Quit]
dbz has quit [Remote host closed the connection]
ogres has quit [Quit: Connection closed for inactivity]
Fr4n has quit [Read error: Connection reset by peer]
dbz has joined #ruby
dbz has quit [Read error: Connection reset by peer]
dbz has joined #ruby
chouhoulis has quit [Ping timeout: 252 seconds]
Sauvin has quit [Ping timeout: 246 seconds]
duderonomy has joined #ruby
* Eiam hands baweaver a beer so they can settle in
Nicmavr has quit [Read error: Connection reset by peer]
bkxd has quit [Read error: Connection reset by peer]
xfbs has quit [Quit: afk]
Nicmavr has joined #ruby
bak1an has joined #ruby
xfbs has joined #ruby
schneider has quit [Ping timeout: 268 seconds]
xfbs has quit [Client Quit]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sameerynho has joined #ruby
schneider has joined #ruby
Sauvin has joined #ruby
sauvin_ has joined #ruby
phaul has joined #ruby
bkxd has joined #ruby
Sauvin has quit [Ping timeout: 252 seconds]
beowuff has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
schneider has quit [Quit: WeeChat 2.0.1]
dbz has quit [Remote host closed the connection]
roshanavand has joined #ruby
uplime has joined #ruby
uplime has joined #ruby
Dbugger has joined #ruby
GodFather has quit [Ping timeout: 240 seconds]
uplime has quit [Client Quit]
kurko_ has joined #ruby
uplime has joined #ruby
xfbs has joined #ruby
bkxd has joined #ruby
venmx has quit [Ping timeout: 260 seconds]
bkxd has quit [Read error: Connection reset by peer]
GodFather has joined #ruby
bkxd has joined #ruby
ellcs has joined #ruby
kapil____ has joined #ruby
bkxd has quit [Ping timeout: 252 seconds]
za1b1tsu has quit [Ping timeout: 252 seconds]
clemens3 has joined #ruby
agent_white has joined #ruby
Terens has quit [Ping timeout: 252 seconds]
deathwishdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mroutis has joined #ruby
conta1 has quit [Quit: conta1]
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
impermanence has joined #ruby
bkxd has joined #ruby
dviola has joined #ruby
sauvin_ has quit [Read error: Connection reset by peer]
improv42 has joined #ruby
weaksauce has joined #ruby
kurko_ has joined #ruby
improv42 has quit [Remote host closed the connection]
<cthulchu> we can next in each_line, right?
<apeiros_> yes
<cthulchu> thanks
krawchyk has joined #ruby
improv42 has joined #ruby
conta1 has joined #ruby
clemens3 has quit [Ping timeout: 252 seconds]
discopatrick has quit [Quit: Connection closed for inactivity]
bkxd has quit [Read error: Connection reset by peer]
eckhardt has joined #ruby
clemens3 has joined #ruby
bkxd has joined #ruby
SeepingN has quit [Quit: The system is going down for reboot NOW!]
improv42 has quit [Read error: Connection reset by peer]
improv42 has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
GodFather has quit [Ping timeout: 245 seconds]
bkxd has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
GodFather has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<cthulchu> wow
<cthulchu> I found something weird
<cthulchu> looks like it's possible for a hash to have fields with the same keys
bkxd has joined #ruby
<cthulchu> I didn't know it about them
<cthulchu> so if I set a hash explicitly like hash={"qwe":""} and then do hash["qwe"]="bar", it will end up having two records
<cthulchu> with the same key but different values...
<cthulchu> hm
<cthulchu> Ruby is amazing
<phaul> Ruby is amazing, but you are mistaken there
<phaul> {"qwe":""} is { :qwe => '' }
<phaul> so not the same keys
<phaul> one is symbol the other is string
<cthulchu> err
<cthulchu> omfg
<cthulchu> I didn't mean symbols!
<cthulchu> thanks! :)
<phaul> np :)
teej has joined #ruby
<cthulchu> so... the correct way would be... asd = {qwe = "qwe", asd = "asd"}?
greengriminal has joined #ruby
<cthulchu> oh
<cthulchu> actually
<cthulchu> should be {"qwe":"qwe"}
<cthulchu> I guess
<uplime> {"abcd" => "efgh"}
<greengriminal> Hey all I'm currently using Ruby 2.3.4 and the following (0.99 + (1.0 * 0.025)).round(2) = 1.01 but in Ruby 2.3.7 I get 1.02
<cthulchu> oh, ok, thanks
<cthulchu> => is the arrow function?
<phaul> cthulchu: we used to have only one hash syntax. the => syntax. then they decided to give a syntactic sugar for symbol keys. that's when all the confusion started
<uplime> cthulchu: its not a function
<phaul> not function. it's a special syntax to define hashes
<cthulchu> ok, thanks
<uplime> key => value
<cthulchu> great, I'll do it then
<uplime> key_as_symbol: vlaue
<greengriminal> For that matter I get the same output on 2.4.0 as well
deathwishdave has joined #ruby
improv42 has quit []
GodFather has quit [Ping timeout: 252 seconds]
rubydoc has joined #ruby
improv42 has joined #ruby
conta1 has quit [Quit: conta1]
<phaul> &ri Hash
duderonomy has joined #ruby
<cthulchu> so that => is only in {}, right?
<phaul> right
<cthulchu> once it's just hash["key"], I can assign
<cthulchu> with =
<phaul> correct
<cthulchu> thanks :)
bmurt has joined #ruby
greengriminal has quit [Quit: This computer has gone to sleep]
bkxd has quit [Read error: Connection reset by peer]
ruurd has joined #ruby
dviola has quit [Quit: WeeChat 2.2]
greengriminal has joined #ruby
improv42 has quit [Remote host closed the connection]
bkxd has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
reber has quit [Remote host closed the connection]
<phaul> &ri Hash, phaul
<phaul> cool. even that works :) how versatile concatenation can be :)
rubydoc has quit [Remote host closed the connection]
phaul has quit [Quit: bye]
phaul has joined #ruby
ivanskie has joined #ruby
ruurd has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rubydoc has joined #ruby
<cthulchu> ok, I'm excited
<cthulchu> I have this Android log that I parse in the runtime
<cthulchu> and there was an issue cuz the log grew rapidly and I didn't have a good way to solve the issue.
<cthulchu> I can't delete it cuz Genymotion won't create a file after that
SeepingN has joined #ruby
<cthulchu> but what I can do is remember the line number that I used before and do my analysis from there on
<cthulchu> or rather file reading
<cthulchu> sounds super cool
<cthulchu> although I would have to use @@
<cthulchu> but hey, it's not that bad
mroutis has quit [Ping timeout: 272 seconds]
spiette has quit [Ping timeout: 260 seconds]
<cthulchu> so the question is... how do I read file starting from a specific line? I looked at arguments in each_line and it seems to have only two: separator and limit
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<phaul> &ri IO#seek , cthulchu
<cthulchu> it will be significantly faster than each_line, right?
chouhoulis has joined #ruby
<cthulchu> I don't like the idea of seeking the line number
<phaul> ignore it, not good for your question sorry.
<cthulchu> ok
<cthulchu> I can't find a good solution
<phaul> my bet is that there is none. Even at filesystem / OS level, the system has no idea where the newlines are
baweaver is now known as lemur
lemur is now known as baweaver
<cthulchu> crap
<cthulchu> I was hoping that files are something like arrays
<cthulchu> hell this is bad
<cthulchu> well then I guess seek it is?
agent_white has quit [Ping timeout: 252 seconds]
<cthulchu> I just find where the line number is and start iterating from there?
<cthulchu> can I do that?
<phaul> but how do you know where to seek to ?
<cthulchu> I will supply the line number
<cthulchu> I parse the same file many times for many tests
dviola has joined #ruby
<cthulchu> so I save the last used line number
<cthulchu> in a static variable
agent_white has joined #ruby
<cthulchu> and then I will use it for every next iteration to start reading from
<phaul> yes , that can work
<cthulchu> there is another approach where I only iterate through the last N lines, but it's not as reliable
Xiti has quit [Quit: Xiti]
<cthulchu> hell this documentation is quite hard to read
<cthulchu> looks like seek is not quite good at starting from somewhere meaningful
<cthulchu> it always starts from the beginning of the file
<cthulchu> and then you only influence the direction and limit of search
dviola has quit [Quit: WeeChat 2.2]
<cthulchu> whereas I need it to start from the specific line
<cthulchu> number
<cthulchu> I guess I'd use lazy for it
<phaul> I thought you said you want to store a location from previous run and then seek to it next time
lunarkitty has quit [Quit: WeeChat 1.9.1]
<phaul> that can be achieved with seek. but it will be byte position
<cthulchu> from it
<cthulchu> first iteration: seeking from 0 to 289, which happens to be the eof. second iteration: seeking from 289 to the new eof
<cthulchu> and so on
<cthulchu> I also need a block and .each for seek
<cthulchu> nah
<cthulchu> it's not for seek
<cthulchu> aha! whence!
<cthulchu> whence can change the position
<cthulchu> no, it cant
<cthulchu> maybe rewind?
<cthulchu> like a smart rewind
<cthulchu> pfff
<cthulchu> I have no clue
tdy has quit [Ping timeout: 246 seconds]
Xiti has joined #ruby
<phaul> I don't see how this saves you anything. It will read in everything
mroutis has joined #ruby
<phaul> maybe wont parse everything as CSV which is a save...
<havenwood> &ri IO#pread
LiftLeft2 has joined #ruby
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
deathwishdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
LiftLeft has quit [Ping timeout: 252 seconds]
<phaul> havenwood: sorry my rubydoc.info.stdlib/core/ prefix paste bot is in very early stages :)
<havenwood> phaul: I think the docs.ruby-lang.org docs would make the best ri links.
<havenwood> phaul: nice
<apeiros_> you shouldn't use non-csv reading methods to advance in a csv (assuming the file does not consist of partially non-csv values)
<apeiros_> reason: a single csv row may very well contain newlines
<apeiros_> TIL pread, though. nice.
jcalla has quit [Quit: Leaving]
jcalla has joined #ruby
deathwishdave has joined #ruby
LiftLeft2 has quit [Ping timeout: 240 seconds]
dmitch has joined #ruby
greengriminal has quit [Quit: This computer has gone to sleep]
<phaul> but if this is just continuing from where you left of when that was an EOF (assuming that EOFs only happen at correct line boundaries) then you can seek to that byte position and continue
bkxd has joined #ruby
tdy has joined #ruby
asphyxia has joined #ruby
deathwishdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
asphyxia has quit [Ping timeout: 240 seconds]
kurko_ has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
Dbugger has quit [Remote host closed the connection]
bkxd has joined #ruby
<phaul> apeiros_: can you find derpy's code - if it's public?
<apeiros_> didn't find it :( I'll try to contact adaedra
<phaul> ok thanks
SeepingN has quit [Quit: The system is going down for reboot NOW!]
gheegh has joined #ruby
lxsameer has joined #ruby
<havenwood> cthulchu: for the heck of it, here's reading through a file to find the newlines and preading between offsets. I didn't check it for off-by-one errors :P https://gist.github.com/havenwood/cd200b40ad0d8ebb91f45ea9c9671858
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bkxd has quit [Read error: Connection reset by peer]
lxsameer has quit [Ping timeout: 244 seconds]
Rapture has quit [Quit: Textual IRC Client: www.textualapp.com]
ellcs has quit [Remote host closed the connection]
SeepingN has joined #ruby
tdy has quit [Ping timeout: 240 seconds]
jcalla has quit [Quit: Leaving]
guardian has quit [Remote host closed the connection]
xfbs has quit [Quit: afk]
ellcs has joined #ruby
bkxd has joined #ruby
dmitch has quit [Ping timeout: 240 seconds]
clemens3 has quit [Ping timeout: 272 seconds]
<gheegh> hey all.. anyone using VCR? I'm having some problem figuring out what to do to get my "let" in RSPEC not re-retrieve the page..
<gheegh> https://gist.github.com/wflanagan/59f0434d11079ace97ed4679d503d31d this is an example.. not sure what i'm doing wrong.. the URL is identical.
sameerynho has quit [Ping timeout: 244 seconds]
bkxd has quit [Ping timeout: 272 seconds]
<cthulchu> guys, files should be better
<cthulchu> right!
<cthulchu> byte position!
chouhoulis has quit [Remote host closed the connection]
<cthulchu> phaul, I should remember the last byte and then start reading from there!
<cthulchu> buz bytes are arrays, right?
<cthulchu> I don't need to read through everything now!
<cthulchu> only one problem: can Ruby tackle that?
Lytol has quit [Remote host closed the connection]
<havenwood> cthulchu: You can't find the byte position of the end of a line without reading up to a newline.
<havenwood> cthulchu: Files don't automagically know where newlines are.
<cthulchu> that's fine
<cthulchu> as I said, I read this file in iterations
<cthulchu> I have, say, 20 tests running one after another
<phaul> yeah what you are trying here would work.
<cthulchu> logs from all of them get to the same file
<cthulchu> but I don't need logs from test N 8 in test N 9
<cthulchu> but now the question is even harder
<havenwood> cthulchu: Above I showed an example of iterating through the file by line once, to find which offsets the newlines are located at. Then going through again, and reading between those offsets.
<cthulchu> how do I save the byte position and load it to start iterating from there
<phaul> cthulchu: IO#pos. IO#seek. IO#pos=
<cthulchu> thanks
<cthulchu> havenwood, I can't afford that and it's not very applicable
<phaul> though I've never tried pos=, but seek to byte position should work
<cthulchu> the problem is that I don't need seek to...
<cthulchu> I need seek from
<cthulchu> also seek is weird
<cthulchu> I'm not sure how it works
<cthulchu> I saw its doc
<havenwood> cthulchu: Well, you've got to read through the file once to find the newlines. My example collects those points and uses #pread to read between them. You could read between them whenever you want, but you have to find the newlines if you want to seek to them.
<phaul> cthulchu: seek gets you to a byte position.
<cthulchu> but it seems to return 0
<cthulchu> oh
<cthulchu> and then what do I do with it?
<cthulchu> do I just do file.each_line?
<cthulchu> havenwood, I think I'll try seeking to byte #
<cthulchu> I hope seek is smart enough to treat it as an array and not iterate through the thing
<havenwood> cthulchu: My point is you can't see to the byte of a newline without reading the file to find where those bytes will be.
<cthulchu> havenwood, I described above
<cthulchu> havenwood, I read this file many times and don't want to start from 0 every time
<cthulchu> phaul, will seek work for each_line?
evdubs_ is now known as evdubs
<phaul> talking across purposes...
<phaul> io.seek(100) will get you to byte position 100 (absolute position)
<cthulchu> and then how do I iterate through new lines after that?
<cthulchu> starting from that absolute position
<phaul> I expect io.each_line { to work. let me check ...
<cthulchu> or should I do that right in the each_line loop?
<phaul> no you should seek first, then read the rest
<havenwood> cthulchu: I showed an example of reading through once to find newlines without having the whole file in memory. You could then do the pread for each of those lines at any later point. I didn't show how to do it piecemeal, where you don't read through the whole thing but readline and continue, but that's not a far stretch from my example.
<cthulchu> havenwood, it is useless since the file changes
<havenwood> hahaha
<cthulchu> I mean, the length of it. it's a log file
<cthulchu> so I need to know the address since where to look for new changes
<cthulchu> we figured it should be byte address, which makes perfect sense
<phaul> cthulchu: yes I tried it works as expected
<cthulchu> phaul, could you please show a snippet?
<phaul> io.seek(previous_last_pos); io.each_line { |line| } ; previous_last_pos = io.pos
<cthulchu> BEAUTIFUL!
<cthulchu> amazing
<cthulchu> perfect
<cthulchu> phaul, thanks a lot :)
truenito has joined #ruby
kapil____ has quit [Quit: Connection closed for inactivity]
ellcs has quit [Remote host closed the connection]
ellcs has joined #ruby
bkxd has joined #ruby
<havenwood> gheegh: #let memoizes within the #it, but not between the two
<gheegh> yeah, but i would have thought vcr would have matched it.. and returned the value
<havenwood> gheegh: ahh
<gheegh> since the URL is the same
<cthulchu> is there a way to find eof byte #?
<cthulchu> without iterating through it
<cthulchu> should be in FS
<cthulchu> is it?
<cthulchu> it should be there
<cthulchu> how else do you read from the end
<cthulchu> yeah, for sure
<havenwood> cthulchu: seek to -1?
<phaul> there is IO::SEEK_END to start from the end of the file
<phaul> then offset is 0
<phaul> (IO::SEEK_END for the whence argument of seek)
<havenwood> file.seek(-1, IO::SEEK_END)
<cthulchu> havenwood, cool! thanks!
<cthulchu> haha
<cthulchu> I even saw it before
<phaul> where does that take you if the file is empty? :)
<cthulchu> great question
<cthulchu> hell
<cthulchu> iiiit...
<cthulchu> wow
<cthulchu> where would it take me though?
<cthulchu> did we just found a way to travel in time?
<cthulchu> to brake the space-time continuum?
<cthulchu> hell I'm curious where it would take me
<cthulchu> gonna test
deathwishdave has joined #ruby
deathwishdave has quit [Client Quit]
<phaul> ~
<havenwood> phaul: Errno::EINVAL
<phaul> yeah I checked too :)
<phaul> I think 0 is the right offset
<cthulchu> oh so when we do the argument magic, it's still symbols? like def asd(a:"",b:"",c:"")
<cthulchu> that means that the function accepts links
<cthulchu> right?
<cthulchu> and then if I run asd(a:"qweqwe"), I actually pass a link to a static string?
<cthulchu> I mean, not static, but primitive as hell
krawchyk has quit [Quit: krawchyk]
<cthulchu> nah, no, probably those aren't symbols
<Radar> slowwwwww dowwwwnnnn
SeepingN has quit [Disconnected by services]
SeepingN_ has joined #ruby
weaksauce has quit [Ping timeout: 252 seconds]
edwardthefma has joined #ruby
ellcs has quit [Read error: Connection reset by peer]
RougeR has joined #ruby
RougeR has quit [Max SendQ exceeded]
RougeR has joined #ruby
pastorinni has joined #ruby
SeepingN_ is now known as SeepingN
SeepingN has quit [Quit: The system is going down for reboot NOW!]
SeepingN has joined #ruby
MaiconVieira has quit [Ping timeout: 260 seconds]
truenito has quit [Remote host closed the connection]
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
MoritaShinobu has joined #ruby
bkxd has quit [Ping timeout: 246 seconds]
teej has quit [Quit: Connection closed for inactivity]
_phaul has joined #ruby
moei has quit [Quit: Leaving...]
rubydoc has quit [Ping timeout: 246 seconds]
_phaul has quit [Client Quit]
phaul has quit [Ping timeout: 244 seconds]
lxsameer has joined #ruby
dviola has joined #ruby
DTZUZO_ has quit [Ping timeout: 252 seconds]
uplime has quit [Quit: WeeChat 2.2]
lxsameer has quit [Ping timeout: 252 seconds]
AJA4350 has quit [Quit: AJA4350]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
TheBloke has quit [Ping timeout: 244 seconds]
fluxAeon has quit [Quit: Textual IRC Client: www.textualapp.com]
jcarl43 has quit [Quit: WeeChat 2.2]
impermanence has quit [Remote host closed the connection]
bak1an has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<cthulchu> looks like I made a mistake :(
weaksauce has joined #ruby
<havenwood> cthulchu: the logs rotated? :P
<cthulchu> no
<cthulchu> they dont
MaiconVieira has joined #ruby
<cthulchu> I'll debug and come back
fluxAeon has joined #ruby
ivanskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DTZUZO_ has joined #ruby
gheegh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pastorinni has quit [Remote host closed the connection]
Sina has quit [Quit: Connection closed for inactivity]
<cthulchu> I also shouldn't debug at the end of a day
<cthulchu> I usually end up wasting hours on something trivial
bkxd has joined #ruby
pastorinni has joined #ruby
Dimik has joined #ruby