« Back to channel list

#ruby - 24 February 2019

« Back 1 day Forward 1 day »
[00:02:57] cranq: has joined #ruby
[00:04:10] Swyper: has joined #ruby
[00:39:26] zapata: has joined #ruby
[00:39:59] alnk: has joined #ruby
[01:01:56] Psy-Q: has joined #ruby
[01:28:46] houhoulis: has joined #ruby
[01:58:35] cagomez: has joined #ruby
[01:59:56] arescorpio: has joined #ruby
[02:00:13] Swyper: has joined #ruby
[02:07:22] apparition: has joined #ruby
[02:12:51] AndroidKitKat: has joined #ruby
[02:12:58] def_jam: has joined #ruby
[02:14:02] barg: has joined #ruby
[02:15:33] bruul: has joined #ruby
[02:16:43] barg: i'm getting an error when I try to run selenium in ruby https://gist.github.com/gartha1/5fe5da228a7302f2acc0ae66a407aeb8
[02:17:01] barg: Exception `LoadError' at C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55 - cannot load such file -- selenium-webdriver
[02:17:24] barg: Exception `Errno::EADDRNOTAVAIL' at C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.141.0/lib/selenium/webdriver/common/socket_lock.rb:61 - The requested address is not va
[02:17:25] barg: its context. - bind(2) for "127.0.0.1" port 9514
[02:21:42] donofrio: has joined #ruby
[02:27:50] code_zombie: has joined #ruby
[02:32:01] donofrio: has joined #ruby
[02:32:10] houhoulis: has joined #ruby
[02:35:55] Swyper: has joined #ruby
[02:43:25] donofrio: has joined #ruby
[02:48:59] Swyper: has joined #ruby
[03:22:32] hiroaki: has joined #ruby
[03:24:46] cagomez: has joined #ruby
[03:25:57] donofrio: has joined #ruby
[03:39:43] Renich: has joined #ruby
[03:58:28] al2o3-cr: has joined #ruby
[04:02:49] wolfshappen: has joined #ruby
[04:10:32] braincrash: has joined #ruby
[04:24:47] Nicmavr: has joined #ruby
[04:25:53] cagomez: has joined #ruby
[04:34:13] Swyper: has joined #ruby
[04:44:29] jobewan: has joined #ruby
[05:04:50] planigan: has joined #ruby
[05:12:11] _whitelogger: has joined #ruby
[05:14:11] doomspork: has joined #ruby
[05:34:02] noAKA: has joined #ruby
[05:44:05] fluxAeon: has joined #ruby
[05:45:46] orbyt_: has joined #ruby
[05:46:36] noAKA: Anyone have a second to help out with what I think is a scope problem? https://dpaste.de/FrUc. Method at line 37, description in inline commment.
[06:15:14] baweaver: noAKA: I'd bet on some form of eval (instance, module, class)
[06:15:42] baweaver: If you made locals right above it I bet it works
[06:16:49] baweaver: loddbot = Cinch::Bot.new; loddbot.configure do ... end
[06:16:52] baweaver: Try that instead
[06:17:56] baweaver: Bingo: `instance_eval(&b) if block_given?`
[06:18:01] baweaver: https://www.rubydoc.info/github/cinchrb/cinch/Cinch/Bot#initialize-instance_method
[06:22:25] noAKA: I'll give that a shot
[06:27:05] noAKA: baweaver: Worked! thanks a ton
[06:45:52] blackmesa1: has joined #ruby
[06:55:41] rippa: has joined #ruby
[06:59:05] laaron: has joined #ruby
[07:22:22] arekushi: has joined #ruby
[07:42:33] dellavg__: has joined #ruby
[08:00:37] KeyJoo: has joined #ruby
[08:08:37] reber: has joined #ruby
[08:09:51] conta: has joined #ruby
[08:17:24] Dbugger: has joined #ruby
[08:18:00] hiroaki: has joined #ruby
[08:24:30] ua: has joined #ruby
[09:07:36] blackmesa1: has joined #ruby
[09:10:49] t0xik: has joined #ruby
[09:17:19] sameerynho: has joined #ruby
[09:21:20] fluxAeon: has joined #ruby
[09:38:07] gix: has joined #ruby
[09:38:30] conta: has joined #ruby
[10:02:05] wolfshappen_: has joined #ruby
[10:14:44] Fernando-Basso: has joined #ruby
[10:17:46] dhollinger: has joined #ruby
[10:33:13] adgtl: has joined #ruby
[10:36:26] mikecmpbll: has joined #ruby
[10:38:13] xrexeon: has joined #ruby
[10:40:47] ricotuco: has joined #ruby
[10:41:12] ams__: has joined #ruby
[11:03:04] clemens3_: has joined #ruby
[11:04:37] conta: has joined #ruby
[11:24:55] laaron: has joined #ruby
[11:41:57] BTRE: has joined #ruby
[12:10:28] conta: has joined #ruby
[12:40:53] Inline: has joined #ruby
[12:51:08] mikecmpbll: has joined #ruby
[12:52:20] mangold: has joined #ruby
[12:54:55] AJA4350: has joined #ruby
[12:58:24] SCHAPiE: has joined #ruby
[13:02:20] Inline: has joined #ruby
[13:05:57] volkov: has joined #ruby
[13:06:31] mangold: has joined #ruby
[13:12:17] lucasb: has joined #ruby
[13:23:54] conta1: has joined #ruby
[13:54:40] kent\n: has joined #ruby
[13:59:27] mnemon: has joined #ruby
[14:04:08] catbusters: has joined #ruby
[14:17:43] NeilCarvalho: has joined #ruby
[14:34:30] laaron: has joined #ruby
[14:37:09] Inline: has joined #ruby
[14:45:22] ravenousmoose: has joined #ruby
[14:54:03] xco: has joined #ruby
[14:54:59] mangold: has joined #ruby
[15:01:22] Swyper: has joined #ruby
[15:01:27] zapata: has joined #ruby
[15:02:21] manakanapa: has joined #ruby
[15:02:27] xco: i was trying to help a friend learn Ruby with this simple excercise but I failed to expalin to him line 28 https://gist.github.com/xcobar/afde617a4abd23d2eae783c4403a51a6 we wrote this program together step-by-step but on line 28 he had initially written “else @points += 1” without “results[0] == results[1]”
[15:03:23] xco: i couldn’t answer his question why just “else @points += 1” didn’t work (returned 4 instead of 7) but i just knew he had to put “elsif results[0] == results[1]”
[15:03:51] xco: can anyone tell me why just “else @points += 1” didn’t work. i need this explanation for myself and for him :)
[15:05:53] manakanapa1: has joined #ruby
[15:07:45] mnemon: xco: I just tested it with else and it still returned 7
[15:09:11] xco: mnemon: thanks! so he must have messed something on his computer that i missed
[15:09:53] xco: mnemon: thanks a lot :)
[15:12:30] phaul: @points += [1, 3, 0][results[0] <=> results[1]]
[15:13:01] phaul: but don't write code like this
[15:14:18] xco: phaul: what do you mean? I know myself to write it this way like you have but i’m helping a beginner out. he wouldn’t undestand this and it would be hard for me to explain <=> this to a complete noob that’s why i we wrote it the way we did
[15:14:32] xco: if it makes any sense
[15:19:05] phaul: it's unecesarrily trying to be clever sacrificing clarity for shortness
[15:37:21] xrexeon: has joined #ruby
[15:47:25] venmx: has joined #ruby
[15:55:53] mangold: has joined #ruby
[16:02:23] wolfshappen: has joined #ruby
[16:40:35] ravenousmoose: has joined #ruby
[16:44:56] doomspork: has joined #ruby
[17:05:09] conta: has joined #ruby
[17:10:28] orbyt_: has joined #ruby
[17:22:10] tdy: has joined #ruby
[17:33:25] gix: has joined #ruby
[17:37:58] phaul: has joined #ruby
[17:45:16] hiroaki_: has joined #ruby
[17:48:59] Paraxial: has joined #ruby
[17:55:31] houhoulis: has joined #ruby
[18:12:48] Swyper: has joined #ruby
[18:22:30] dellavg__: has joined #ruby
[19:05:32] al2o3-cr: has joined #ruby
[19:06:59] dmwit: I don't know how to Google this. If I've defined a [] method for my class, how do I call it from within another method of that same class?
[19:07:28] dmwit: [foo] seems like it would just create a one-element list...
[19:11:32] doomspork: has joined #ruby
[19:12:35] hiroaki_: has joined #ruby
[19:25:16] ravenousmoose: has joined #ruby
[19:28:00] conta: has joined #ruby
[19:28:50] dmwit: When I write `x = Enumerator.new {|y| y << 1; print 2; y << 2}`, then later I `x.each {|v| print v}`, the call to `y << 1` transfers control back from the original block into `x.each`. How the heck does that work?? Can I write my own class that behaves that way somehow?
[19:29:34] leftylink: the only way I found to call [] was self.[foo]
[19:29:43] leftylink: er, without the dot
[19:29:54] leftylink: self[foo], or I guess self.[](foo) would also work
[19:30:32] leftylink: given that you can do maybe_an_array&.[](foo) , seems logical that self.[](foo) would work
[19:30:40] dmwit: Okay, cool.
[19:31:03] dmwit: Didn't know about self, but it makes sense that something like that would exist.
[19:33:39] leftylink: the passing of control used to invite some sort of discussion about https://ruby-doc.org/core-2.5.0/Continuation.html but nowadas I guess people prefer https://ruby-doc.org/core-2.5.0/Fiber.html . I haven't delved into them much
[19:35:56] bga57: has joined #ruby
[19:39:13] ravenousmoose: has joined #ruby
[19:51:39] ellcs: has joined #ruby
[19:55:32] reber: has joined #ruby
[20:41:17] cd: has joined #ruby
[20:43:24] agent_white: has joined #ruby
[20:45:03] c-c: has joined #ruby
[20:49:50] Swyper: has joined #ruby
[21:06:06] xco: has joined #ruby
[21:26:31] xrexeon: has joined #ruby
[21:41:55] orbyt_: has joined #ruby
[22:00:56] clemens3_: has joined #ruby
[22:02:39] wolfshappen_: has joined #ruby
[22:03:59] Arahael: has left #ruby: ("WeeChat 2.0.1")
[22:05:22] tekk: has joined #ruby
[22:12:52] xco: has joined #ruby
[22:28:55] nowhere_man: has joined #ruby
[22:41:42] zapata: has joined #ruby
[22:48:08] al2o3-cr: has joined #ruby
[22:54:25] cthulchu_: has joined #ruby
[23:00:35] c-c: I want to pass a block into a new, and into a method from there, into a method which yields. Whats the correct way to do this? Is it OK to bind the new proc into a var? like keep doing ablock = Proc.new if block_given?
[23:01:50] phaul: if you use yhe & syntax on the argument list it automatically binds it to an argument
[23:02:13] phaul: then you can assign it to any instance variable like everyting else.
[23:03:18] catbusters: has joined #ruby
[23:03:19] phaul: &>> class X; def initialize(&block); @x = block; end; def foo; @x.call; end; end; x = X.new { hello } ; x.foo
[23:03:20] rubydoc: # => undefined local variable or method `hello' for main:Object (NameError) (https://carc.in/#/r/6d0h)
[23:03:30] phaul: &>> class X; def initialize(&block); @x = block; end; def foo; @x.call; end; end; x = X.new { 'hello' } ; x.foo
[23:03:31] rubydoc: # => "hello" (https://carc.in/#/r/6d0i)
[23:09:42] c-c: Ahem, why didn't I realize the block can be bound to a class var
[23:12:03] c-c: Anyway, I was thinking that &block in an argument list was 10x slower than Proc.new - read something about it somewhere.
[23:14:59] ellcs: has joined #ruby
[23:15:36] phaul: It's probably slower than yield because then you don't have to proc-ify the block. But here the proc object is created either way. I don't beleive 10x but I don't have numbers. One would have to measure. But even then I would say don't optimize up front. Do your algorithm in a sane way and when it's slow profile it.
[23:19:13] c-c: it may be 10x just for the case where the block is not ever run
[23:19:54] c-c: never nil.call
[23:20:03] c-c: - or something
[23:27:00] c-c: phaul: how would you pass the @x? Like say when instantiating another class with new in method foo?
[23:27:16] c-c: like &@x ?
[23:28:23] c-c: Or maybe: Aklas.new(foo) @x
[23:28:42] phaul: & on method declare "procifies" wheras on call "blockifies" back. so yes, that's how map(&method(:blah)) works
[23:28:42] rubydoc: parser error at position 0 around ` '
[23:28:49] c-c: erm, foo was a poor choice for unambiguity there on my part
[23:30:37] phaul: but I'm don't fully understand your example or what it's trying.
[23:31:08] phaul: I'm not sure I fully understand --- edited lines after I wrote it
[23:32:32] phaul: write a small paste or something, and if it doesn't work we can help
[23:32:32] c-c: &>> class Zero; def initialize; Proc.new.call if block_given?; end; end; class One; def initialize; @y = Proc.new if block_given?; Zero.new? @y; end;
[23:32:32] rubydoc: # => (https://carc.in/#/r/6d0j)
[23:33:04] c-c: wow it doesn't error
[23:33:28] c-c: &>> class Zero; def initialize; Proc.new.call if block_given?; end; end; class One; def initialize; @y = Proc.new if block_given?; Zero.new? @y; end; One.new { p 0 }
[23:33:28] rubydoc: # => (https://carc.in/#/r/6d0k)
[23:33:38] phaul: syntax errors are not reported back correctly by the bot
[23:33:46] phaul: click on the links
[23:36:31] c-c: Weird! so it works if: class Zero; def initialize; Proc.new.call if block_given?; end; end; class One; def initialize; @y = Proc.new if block_given?; Zero.new &@y; end; end; One.new { p 0 }
[23:38:10] nowhere_man: has joined #ruby
[23:48:02] laaron: has joined #ruby
[23:56:34] t0xik: has joined #ruby