« Back to channel list

#ruby - 27 December 2018

« Back 1 day Forward 1 day »
[00:01:05] baweaver: al2o3-cr: 40 minutes, I lied.
[00:01:32] phaul: only 3 to go :)
[00:02:04] laaron: has joined #ruby
[00:03:47] al2o3-cr: haha cool that was quick, one little snitch it's Enumerable#chain and Enumerator#+
[00:08:32] al2o3-cr: but other that that it looks good to me ;)
[00:10:13] yqrashawn: has joined #ruby
[00:15:44] elphe: has joined #ruby
[00:16:01] baweaver: https://medium.com/@baweaver/i-want-to-paste-in-pry-5215b4f971ea
[00:17:50] al2o3-cr: damn, your on a roll now ;)
[00:19:14] baweaver: Mostly finishing half-written articles I was too lazy to publish before
[00:19:52] sarink: has joined #ruby
[00:19:53] al2o3-cr: that 30 is certainly in sight now :D
[00:24:53] ellcs: has joined #ruby
[00:27:04] phaul: baweaver: if you do all of them now, what are you going to do tomorrow :)
[00:27:18] al2o3-cr: eat more turkey ;)
[00:27:29] baweaver: Write more of my book probably
[00:32:07] al2o3-cr: baweaver: going to use that pry paste, i'll have to use xclip though.
[00:32:19] al2o3-cr: nice indeed.
[00:32:23] baweaver: Most of it is functionally the same.
[00:32:50] baweaver: Still danged annoying though because of the way TMUX binds things
[00:33:25] al2o3-cr: is screen just as bad?
[00:35:45] baweaver: ACTION shrugs
[00:35:49] baweaver: Never used it
[00:35:55] al2o3-cr: no worries.
[00:38:24] phaul: I most of the time use https://github.com/t9md/vim-ruby-xmpfilter to play with the code. it's old but still works fine.
[00:39:03] ixti: has joined #ruby
[00:40:36] al2o3-cr: phaul: i don't think i'm ever out of pry lol ;)
[00:47:33] yqrashawn: has joined #ruby
[00:59:36] SeepingN: has joined #ruby
[01:02:04] tdy: has joined #ruby
[01:03:21] yqrashawn: has joined #ruby
[01:03:23] laaron: has joined #ruby
[01:11:01] laaron-: has joined #ruby
[01:13:15] laaron: has joined #ruby
[01:18:50] elphe: has joined #ruby
[01:34:42] sonofentropy: has joined #ruby
[01:36:18] sarink: has joined #ruby
[01:43:49] Menteb: has joined #ruby
[01:45:03] yqrashawn: has joined #ruby
[01:46:38] ellcs: has joined #ruby
[01:47:18] hutch: has joined #ruby
[01:47:26] RougeR: has joined #ruby
[02:03:59] laaron: has joined #ruby
[02:06:02] ellcs: has joined #ruby
[02:06:07] remi: has joined #ruby
[02:08:48] cschneid: has joined #ruby
[02:13:32] elphe: has joined #ruby
[02:14:51] agent_white: I put pry in my coffee in the mornin'.
[02:19:39] lewis: happy new year!!
[02:19:44] donofrio: has joined #ruby
[02:19:47] lewis: anyone work at basecamp here?
[02:25:33] tdy: has joined #ruby
[02:31:03] sarink: has joined #ruby
[02:43:07] Xiti: has joined #ruby
[02:43:44] donofrio: has joined #ruby
[02:50:38] shakes: has joined #ruby
[02:56:29] remi: has left #ruby: ()
[02:56:29] aupadhye: has joined #ruby
[02:57:05] hutch: has joined #ruby
[02:58:50] davidw: has joined #ruby
[03:01:22] laaron-: has joined #ruby
[03:01:29] quipa: has joined #ruby
[03:03:45] donofrio: has joined #ruby
[03:07:34] JoeA2552: has joined #ruby
[03:11:01] MasterAsia: has joined #ruby
[03:17:20] Kn|t3: has joined #ruby
[03:22:17] JoeA2552: has joined #ruby
[03:23:45] baweaver: al2o3-cr / phaul / havenwood: Wanna see something awful?
[03:25:36] elphe: has joined #ruby
[03:26:57] baweaver: https://gist.github.com/baweaver/b710b52a1b64302ca1f1d13fba76aa93
[03:28:56] baweaver: Looks like operator precedence screws with method_missing hackery
[03:29:09] darkhanb: has joined #ruby
[03:29:15] baweaver: _Might_ be able to get away with it by defining common operators precluding method_missing, not sure.
[03:29:59] Ohga: has joined #ruby
[03:32:00] Ohga: *thumbsup*
[03:34:12] JoeA2552: has joined #ruby
[03:34:15] Ohga: has left #ruby: ()
[03:34:28] nowhere_man: has joined #ruby
[03:39:40] hutch: has joined #ruby
[03:48:18] kapil____: has joined #ruby
[03:50:00] hutch: has joined #ruby
[03:55:21] esrse: has joined #ruby
[04:00:56] elphe: has joined #ruby
[04:04:09] baweaver: The numbers were grouping instead of applying to eachother.
[04:09:55] sgen: has joined #ruby
[04:10:00] braincrash: has joined #ruby
[04:10:59] Azure: has joined #ruby
[04:13:37] cschneid: has joined #ruby
[04:21:10] _whitelogger: has joined #ruby
[04:32:37] laaron: has joined #ruby
[04:35:38] uplime: has joined #ruby
[04:42:21] cschneid: has joined #ruby
[04:47:21] sauvin: has joined #ruby
[04:53:43] donofrio: has joined #ruby
[05:00:03] elphe: has joined #ruby
[05:01:37] nowhereman: has joined #ruby
[05:03:37] laaron: has joined #ruby
[05:04:33] hutch: has joined #ruby
[05:10:54] sarink: has joined #ruby
[05:15:08] ur5us: has joined #ruby
[05:17:03] baweaver: https://medium.com/@baweaver/sf-abusing-operators-and-method-missing-ced78ab428cb
[05:17:06] baweaver: al2o3-cr: 29
[05:29:59] tdy: has joined #ruby
[05:31:12] ogres: has joined #ruby
[05:36:21] rippa: has joined #ruby
[05:37:43] Kn|t3: has left #ruby: ("Leaving")
[05:46:56] hutch: has joined #ruby
[05:53:11] paranoicsan: has joined #ruby
[05:54:42] dada1: has joined #ruby
[05:54:59] dada1: can I store something like NS::MyClass into klass
[05:55:09] dada1: or should I always store NS::MyClass.new into klass
[05:55:24] dada1: What should I name "klass" if it's not initialized?
[05:56:25] Renich: has joined #ruby
[06:05:07] sgen: has joined #ruby
[06:12:08] tdy1: has joined #ruby
[06:22:46] elphe: has joined #ruby
[06:34:47] tdy2: has joined #ruby
[06:37:24] cthulchu_: has joined #ruby
[06:45:11] _whitelogger: has joined #ruby
[06:52:15] dellavg_: has joined #ruby
[07:02:53] reber: has joined #ruby
[07:04:38] paranoicsan: has joined #ruby
[07:07:56] johnny56: has joined #ruby
[07:14:27] cschneid: has joined #ruby
[07:22:37] laaron: has joined #ruby
[07:25:00] gix: has joined #ruby
[07:29:55] JoeA2552: has joined #ruby
[07:31:36] mclee: has joined #ruby
[07:32:40] KeyJoo: has joined #ruby
[07:34:22] mclee: has joined #ruby
[07:38:30] JoeA2552: has joined #ruby
[07:39:05] mclee: has joined #ruby
[07:50:25] mclee: has joined #ruby
[07:52:00] mclee: has joined #ruby
[07:53:56] tdy3: has joined #ruby
[07:54:11] mclee: has joined #ruby
[07:59:10] prestorium: has joined #ruby
[08:03:37] laaron-: has joined #ruby
[08:04:58] neuraload: has joined #ruby
[08:05:01] Tempesta: has joined #ruby
[08:07:04] johnny56: has joined #ruby
[08:19:02] cthu|: has joined #ruby
[08:19:50] JoeA2552: has joined #ruby
[08:20:41] MasterAsia: has joined #ruby
[08:25:15] sarink: has joined #ruby
[08:33:26] sarink: has joined #ruby
[08:34:31] cschneid: has joined #ruby
[08:36:58] sarink: has joined #ruby
[08:41:31] sonofentropy: has joined #ruby
[09:04:41] laaron: has joined #ruby
[09:12:06] johnny56: has joined #ruby
[09:29:51] cthulchu_: has joined #ruby
[09:32:54] Guest49234: has joined #ruby
[09:40:49] cthu|: has joined #ruby
[09:50:48] conta: has joined #ruby
[09:57:01] vonfry: has joined #ruby
[10:00:56] al2o3-cr: baweaver: nice, i had to read that few times to even understand what it was you were doing :D
[10:05:11] laaron: has joined #ruby
[10:07:20] cthulchu_: has joined #ruby
[10:11:25] cschneid: has joined #ruby
[10:12:24] cthulchu: has joined #ruby
[10:13:07] cthu|: has joined #ruby
[10:20:59] esrse: has joined #ruby
[10:27:19] mikecmpbll: has joined #ruby
[10:34:20] venmx: has joined #ruby
[10:36:46] canton7: has joined #ruby
[10:44:32] tiff: has joined #ruby
[10:50:08] sonofentropy: has joined #ruby
[10:52:28] uplime: has joined #ruby
[11:04:57] laaron: has joined #ruby
[11:09:27] clemens3: has joined #ruby
[11:13:45] tdy3: has joined #ruby
[11:17:19] elphe: has joined #ruby
[11:28:14] szulak_: has joined #ruby
[11:43:13] venmx: has joined #ruby
[11:43:26] al2o3-cr: has joined #ruby
[11:51:48] al2o3-cr: has joined #ruby
[11:59:35] dellavg_: has joined #ruby
[12:04:38] laaron: has joined #ruby
[12:15:36] AJA4350: has joined #ruby
[12:16:43] al2o3-cr: has joined #ruby
[12:25:52] Nicmavr: has joined #ruby
[12:39:00] kapil____: has joined #ruby
[12:48:10] _whitelogger: has joined #ruby
[12:57:25] elphe: has joined #ruby
[13:02:10] Inline: has joined #ruby
[13:03:19] laaron-: has joined #ruby
[13:03:29] uplime: has joined #ruby
[13:25:03] m0w: has joined #ruby
[13:26:25] venmx: has joined #ruby
[13:28:15] cschneid: has joined #ruby
[13:29:32] sonofentropy: has joined #ruby
[13:38:28] uplime: has joined #ruby
[13:48:57] mostlybadfly: has joined #ruby
[13:54:51] tdy3: has joined #ruby
[14:04:01] laaron: has joined #ruby
[14:05:34] ellcs: has joined #ruby
[14:15:46] uplime: has joined #ruby
[14:15:54] troulouliou_div2: has joined #ruby
[14:20:06] ellcs: has joined #ruby
[14:32:03] varesa: has joined #ruby
[14:36:52] Mike11: has joined #ruby
[14:41:05] bmurt: has joined #ruby
[14:46:21] MasterAsia: has joined #ruby
[14:51:27] polishdub: has joined #ruby
[14:52:03] cschneid: has joined #ruby
[14:56:46] sonofentropy: has joined #ruby
[15:00:18] neuraload: has joined #ruby
[15:00:41] r3dc0d3r: has joined #ruby
[15:01:00] donofrio: has joined #ruby
[15:01:01] szulak_: has joined #ruby
[15:02:38] Eldritch: has joined #ruby
[15:03:46] leonthemisfit: has joined #ruby
[15:04:25] gix: has joined #ruby
[15:04:38] Eldritch: has joined #ruby
[15:04:40] laaron: has joined #ruby
[15:07:40] Eldritch: has joined #ruby
[15:08:17] donofrio: has joined #ruby
[15:08:40] MasterAsia: has joined #ruby
[15:14:20] Rapture: has joined #ruby
[15:15:30] ellcs: has joined #ruby
[15:20:15] donofrio: has joined #ruby
[15:21:36] szulak_: has joined #ruby
[15:27:54] supergeek: has joined #ruby
[15:30:26] mspo: so I asked this already but didn't understand the answer. Is there a way to explicitly a method without arguments? like foo() but with foo(nil) or similar
[15:31:43] phaul: you mean explicitly call a method? yes parens force the parser to take it as a method name even if a local var exist with the same name
[15:32:16] phaul: foo(nil) is different though, that pases 1 argument with value nil
[15:32:17] cschneid: has joined #ruby
[15:33:00] phaul: &>> x = 7; def x; -7; end; x()
[15:33:04] rubydoc: # => -7 (https://carc.in/#/r/5v4f)
[15:33:09] phaul: &>> x = 7; def x; -7; end; x
[15:33:09] rubydoc: # => 7 (https://carc.in/#/r/5v4g)
[15:34:30] mspo: phaul: I am probably way off base but I wanted to do something like this: P.new( foo.empty? : nil ? foo )
[15:36:35] mspo: phaul: which is probably just a bad idea because I'm just learning but I was trying to find a good way to test for the argument
[15:38:15] havenwood: mspo: https://gist.github.com/havenwood/cde09db1143ec3412f0c70fa0a918e73
[15:40:31] cschneid: has joined #ruby
[15:41:29] Cthulu201: has joined #ruby
[15:42:13] mspo: havenwood: thanks I think I get it
[15:42:27] mspo: havenwood: *[] expands the (empty) array into nothing?
[15:42:50] havenwood: mspo: Yes, or if there were multiple items in the Array it would pass them as multiple arguments.
[15:48:10] laaron: has joined #ruby
[15:48:33] mspo: havenwood: okay cool. ruby still doesn't like my bad idea but I appreciate the lesson in the *[] syntax :)
[15:49:06] mspo: nbd I just skipped having a default value for the paramter and put better testing in the initialize
[15:49:39] havenwood: mspo: If you can show us your code we might have better suggestions.
[15:49:43] mspo: which got me to use a begin/rescue
[15:49:52] mspo: havenwood: I'm kind of live hacking as I learn
[15:53:31] elphe: has joined #ruby
[16:00:10] tiff: has joined #ruby
[16:04:40] lxsameer: has joined #ruby
[16:29:11] davidw: has joined #ruby
[16:31:09] quipa: has joined #ruby
[16:33:17] jottr: has joined #ruby
[16:36:42] elphe: has joined #ruby
[16:45:21] sgen: has joined #ruby
[16:46:09] \void: has joined #ruby
[16:46:28] elphe: has joined #ruby
[16:49:38] hutch: has joined #ruby
[16:51:13] noodle: has joined #ruby
[16:53:48] sameerynho: has joined #ruby
[16:55:30] sgen_: has joined #ruby
[17:11:23] szulak_: has joined #ruby
[17:15:37] KeyJoo: has joined #ruby
[17:16:49] darkhanb: has joined #ruby
[17:24:54] ellcs: has joined #ruby
[17:32:18] cthulchu_: has joined #ruby
[17:32:40] za1b1tsu: has joined #ruby
[17:37:34] clemens3_: has joined #ruby
[17:41:30] clemens3: has joined #ruby
[17:43:17] BH23: has joined #ruby
[17:46:18] clemens3_: has joined #ruby
[17:48:40] solocshaw: has joined #ruby
[17:52:03] DTZUZO: has joined #ruby
[17:52:25] evdubs_: has joined #ruby
[17:57:45] clemens3_: has joined #ruby
[17:57:49] agent_white: has joined #ruby
[18:01:50] cthu|: has joined #ruby
[18:04:18] cthu|: has joined #ruby
[18:09:00] marz_d`ghostman: has joined #ruby
[18:09:30] marz_d`ghostman: I have my gems installed via bundle install --path .bundle on my project root directory. How do I run ruby so that it sees the gems?
[18:09:50] phaul: bundle exec
[18:11:41] phaul: $ bundle exec ruby some.rb, $ bundle exec some_executable etc.
[18:12:11] phaul: $ is the prompt ...
[18:12:27] clemens3: has joined #ruby
[18:12:39] marz_d`ghostman: phaul: Ah, thanks. Also, how do I access instance methods inside at_exit blocks? I placed an at_exit block that I would like to email me if $ERROR_INFO
[18:13:06] baweaver: I did more bad things to Ruby: https://medium.com/@baweaver/sf-abusing-operators-and-method-missing-ced78ab428cb
[18:13:33] mostlybadfly: has joined #ruby
[18:13:50] phaul: ohai, looking
[18:13:56] baweaver: marz_d`ghostman: What's the full code?
[18:16:25] ellcs: has joined #ruby
[18:16:26] phaul: baweaver: oh yeah I saw this in the morning. I read the issue you had with operator precedence, I haven't really understood it yet though
[18:16:42] baweaver: I figured it our
[18:17:06] baweaver: Sf + 5 * 10 -> Sf + (5 * 10)
[18:17:23] marz_d`ghostman: phaul: https://gist.github.com/marzdgzmn/382217dc13aab3df2429d4fbf514eb66
[18:17:28] clemens3_: has joined #ruby
[18:20:21] phaul: baweaver: oh you mean if one wants left associative parens then they should explicitly do that. That makes sense, i was confused I thought you added some more trickery to force order.
[18:21:06] baweaver: Nope, not without hacking the everloving heck out of the parser :P
[18:21:14] baweaver: I feel like at_exit should not be used in a module, but as a supervisor
[18:21:18] armyriad: has joined #ruby
[18:21:35] baweaver: I doubt it works as an instance method even if included.
[18:22:27] ellcs: has joined #ruby
[18:23:40] marz_d`ghostman: baweaver: What do you mean as a supervisor?
[18:26:26] phaul: &>> def f; x=3; exit; end; at_exit { puts x }
[18:26:27] rubydoc: # => #<Proc:0x000055b4545ad0a8@-e:2> (https://carc.in/#/r/5v53)
[18:27:03] phaul: &>> def f; @x=3; exit; end; at_exit { puts @x }
[18:27:03] rubydoc: # => #<Proc:0x00005612ec70e090@-e:2> ...check link for more (https://carc.in/#/r/5v54)
[18:27:44] phaul: I'm not sure what I've done :)
[18:29:27] phaul: ah, nm I'm tired Im not even calling f..
[18:32:50] venmx: has joined #ruby
[18:33:53] phaul: marz_d`ghostman: send_mail is an instance method of notification. you I think use it as a class method, but I'm not sure what self is in at_exit. Does it work if you extend instead of include?
[18:34:15] sarink: has joined #ruby
[18:34:16] phaul: &>> at_exit { puts self }
[18:34:17] rubydoc: # => #<Proc:0x000055fac510cc80@-e:2> ...check link for more (https://carc.in/#/r/5v55)
[18:36:17] phaul: &>> at_exit { puts self }; class X; exit; end
[18:36:17] rubydoc: # => exit (SystemExit) ...check link for more (https://carc.in/#/r/5v56)
[18:36:45] elphe: has joined #ruby
[18:38:49] phaul: so it seems, that self is what self was at the definition of the block. Doesn't matter where it exits. So just try extend.
[18:39:24] donofrio: has joined #ruby
[18:41:33] za1b1tsu_: has joined #ruby
[18:41:59] tdy3: has joined #ruby
[18:42:41] hutch: has joined #ruby
[18:42:50] marz_d`ghostman: phaul: It gets triggered via Manager.new.run though hence I'm inlcuding it to make it available as an intance method rather than a class metho
[18:43:18] marz_d`ghostman: phaul: thanks for the recommendation, I'll double check.
[18:44:45] sgen_: has joined #ruby
[18:46:56] phaul: &>> class X; at_exit { puts self }; end; 'is it main, or is it X?'
[18:46:57] rubydoc: # => "is it main, or is it X?" ...check link for more (https://carc.in/#/r/5v57)
[18:47:50] phaul: yeah, that's how it works
[18:51:13] cschneid: has joined #ruby
[18:53:39] kapil____: has joined #ruby
[18:59:17] ellcs: has joined #ruby
[19:01:50] mspo: I have another newb question. Why are methods documented (talked about) as Class#stuff but that # is not used as syntax?
[19:02:19] phaul: convention
[19:02:52] phaul: . means a method that's a method of something, something that can receive it
[19:03:16] phaul: for instance methods you need an instance object to receive it.
[19:04:25] phaul: it could be X.new.method , but it's just documentation, so X#method
[19:07:21] y0u: has joined #ruby
[19:13:18] phaul: but there are methods that the class receives and those are denoted with . in the documentation
[19:14:04] lucasb: has joined #ruby
[19:15:52] elphe: has joined #ruby
[19:17:45] cschneid: has joined #ruby
[19:18:50] donofrio: has joined #ruby
[19:23:10] MasterAsia: has joined #ruby
[19:23:49] clemens3: has joined #ruby
[19:25:31] elphe: has joined #ruby
[19:26:57] Renich: has joined #ruby
[19:33:48] clemens3: has joined #ruby
[19:37:27] elphe: has joined #ruby
[19:46:18] donofrio: has joined #ruby
[19:47:18] cuthbert: has joined #ruby
[19:51:21] havenwood: marz_d`ghostman: Matz borrowed the convention from Smalltalk.
[19:52:50] jottr: has joined #ruby
[19:53:02] phaul: havenwood: it was mspo asking that
[19:53:21] havenwood: phaul: oops!
[19:57:07] elphe: has joined #ruby
[20:02:49] tdy3: has joined #ruby
[20:04:54] VladGh: has joined #ruby
[20:07:01] elphe: has joined #ruby
[20:09:10] za1b1tsu: has joined #ruby
[20:11:06] Aqo: has joined #ruby
[20:11:51] hutch: has joined #ruby
[20:14:13] ellcs: has joined #ruby
[20:27:14] code_zombie: has joined #ruby
[20:28:14] cschneid: has joined #ruby
[20:32:28] elphe: has joined #ruby
[20:36:11] _whitelogger: has joined #ruby
[20:42:29] elphe: has joined #ruby
[20:44:35] vutral1: has joined #ruby
[20:48:52] cd: has joined #ruby
[20:49:28] hutch: has joined #ruby
[20:52:12] elphe: has joined #ruby
[21:00:14] Xiti: has joined #ruby
[21:02:17] elphe: has joined #ruby
[21:11:16] tdy: has joined #ruby
[21:18:12] envex: has joined #ruby
[21:19:37] teej: has joined #ruby
[21:25:30] hiroaki: has joined #ruby
[21:46:39] jcalla: has joined #ruby
[21:50:28] cthu|: regex in .include?
[21:51:34] donofrio: has joined #ruby
[21:52:34] cthu|: oh, okay, it doesn't
[21:52:44] cthu|: but I can replace it with .index
[21:52:59] cthu|: index is smart enough to be friends with regex
[21:53:02] sgen_: has joined #ruby
[21:54:27] tag: has joined #ruby
[21:54:39] phaul: match? is the most idiomatic if you just want yes or no
[21:54:59] phaul: it doesn't set the matchdata stuff, so it's faster
[21:56:20] sarink: has joined #ruby
[21:56:57] quipa_: has joined #ruby
[22:01:23] cthu|: phaul, many thanks, I will replace it with match
[22:01:38] cthu|: anyone seen a construction like unless in our langs?
[22:02:16] phaul: cthu|: ok, but note the ? mark at the end. there is also a String#match which is different
[22:02:49] cthu|: my rubocop says I should use =~ instead of match if the data match returns won't be used
[22:02:59] cthu|: I only use it in if
[22:04:00] phaul: well, I just answered that :)
[22:04:36] phaul: it's String#match vs String#match?
[22:05:10] cthu|: I always thought ? means it returns a bool
[22:05:24] cthu|: how does ? work?
[22:05:43] phaul: well, it usually does. but it's just a naming convention.
[22:05:58] phaul: in this case it does, and that's what you need in an if
[22:06:22] phaul: &>> 'string'.match?(/i/)
[22:06:24] rubydoc: # => true (https://carc.in/#/r/5v76)
[22:06:56] jcalla: has joined #ruby
[22:07:22] al2o3-cr: String#=~ is roughly 1.5x slower than String#match? on my machine.
[22:07:24] cthu|: &>> "qwe1" =~ /.*\d/i
[22:07:25] rubydoc: # => 0 (https://carc.in/#/r/5v77)
[22:07:40] cthu|: &>> "qwe1" =~ /.*/
[22:07:40] rubydoc: # => 0 (https://carc.in/#/r/5v78)
[22:08:03] cthu|: eubocop claims =~ is faster
[22:08:08] cthu|: now I want to turn it off
[22:08:19] cthu|: ok, match it is
[22:13:56] mikecmpbll: has joined #ruby
[22:15:39] cschneid: has joined #ruby
[22:18:03] SeepingN: has joined #ruby
[22:24:14] cthu|: how do I properly check if a["b"]["c"] exists?
[22:25:27] cthu|: oh, we can do if "b" in a
[22:26:38] cthu|: even better, hash.key?(some_key)
[22:27:25] orbyt_: has joined #ruby
[22:32:24] comet23: has joined #ruby
[22:36:45] Mike11: has joined #ruby
[22:37:14] bathtub_shark: cthu|: a[:b].nil? will also work
[22:38:08] tdy: has joined #ruby
[22:40:54] phaul: bathtub_shark: careful. :b is a symbol. cthu| used string keys. Also one can store nil? in a hash, which then fails to make a distinction between it's there but nil or it's not there at all
[22:41:24] bathtub_shark: phaul: the latter is a fair point
[22:41:42] bathtub_shark: i mean, the former is too, but the latter is something i forgot to consider
[22:42:14] bathtub_shark: ACTION maybe has some minor refactoring to do.
[22:42:19] tiff: has joined #ruby
[22:44:28] quipa_: has joined #ruby
[22:48:41] quipa_: has joined #ruby
[22:48:51] cthu|: another question
[22:49:04] cthu|: I know that overriding existing functions in existing classes is bad
[22:49:16] cthu|: what about adding new functions to existing classes?
[22:49:41] cthu|: like self.color(string, color) in String
[22:50:51] cthu|: so that I could do something like puts("This test has failed".color("red"))
[22:52:10] phaul: inheritance in itself in most cases is bad. But we can include, refine, prepend
[22:53:42] phaul: Also inheritance is only bad because it enforces that what you create is obeying every contract that the thing obeyed you inherited from. If that's fine then inheritance is fine. But 99.9% of cases ppl yust break contracts. and that's why its mostly bad
[22:54:05] cthu|: what do you mean by contracts?
[22:55:32] phaul: contracts here means the external interface (public methods) to something plus their promise on their behaviour.
[22:55:49] phaul: I give you an example.
[22:57:44] phaul: (JimW's example) Rake::FileList used to inherit Array. That means that a filelist is in every respect an Array. Yes, from one angle it can be indexed, FileLists concatenated etc. But is it really an Array? Can it do #transpose ? Can it store arbitrary types? etc.
[22:59:21] cthu|: oh so there's no match?
[23:00:14] cthu|: if it extends array, it must obey
[23:01:39] cthu|: I don't even know how you can extend a class in a way that doesn't imply implementation of all public methods of the superclass
[23:01:44] cthu|: unless you override them
[23:02:15] phaul: by extending you mean inheritance?
[23:02:31] cthu|: I mean I haven't tried extending of anything in Ruby yet, but I did a lot of it in Java
[23:02:54] cthu|: but Java has a lot more strict OOP structure.
[23:03:30] phaul: If you don't do anything the subclass inherits methods from the super class. the method lookup just walks up the inheritance chain until it finds a class that implements it
[23:04:45] phaul: even ruby core at the very inner core breaks contracts sometimes...
[23:05:23] phaul: Module is a superclass of Class. yet try to include a class somewhere ..
[23:06:42] phaul: (including is somehting that works for Modules but not for Classes)
[23:07:14] m0w: has joined #ruby
[23:07:30] phaul: &>> class X; end; class Y; include X; end;
[23:07:32] rubydoc: # => wrong argument type Class (expected Module) (TypeError) (https://carc.in/#/r/5v7n)
[23:09:06] phaul: so that's a breakage of Liskov substitution in a way
[23:10:36] elphe: has joined #ruby
[23:14:57] cschneid: has joined #ruby
[23:19:48] sarink: has joined #ruby
[23:21:00] orbyt_: has joined #ruby
[23:27:26] segy: has joined #ruby
[23:28:18] MasterAsia: has joined #ruby
[23:33:05] donofrio: has joined #ruby
[23:55:54] cschneid: has joined #ruby
[23:55:55] LightStalker: has joined #ruby