#ruby - 27 December 2018
« Back 1 day Forward 1 day »
[00:03:47] al2o3-cr: haha cool that was quick, one little snitch it's Enumerable#chain and Enumerator#+
[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.
[03:29:15] baweaver: _Might_ be able to get away with it by defining common operators precluding method_missing, not sure.
[05:17:03] baweaver: https://medium.com/@baweaver/sf-abusing-operators-and-method-missing-ced78ab428cb
[10:00:56] al2o3-cr: baweaver: nice, i had to read that few times to even understand what it was you were doing :D
[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: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:42:50] havenwood: mspo: Yes, or if there were multiple items in the Array it would pass them as multiple arguments.
[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
[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: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: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:17:23] marz_d`ghostman: phaul: https://gist.github.com/marzdgzmn/382217dc13aab3df2429d4fbf514eb66
[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:27:03] rubydoc: # => #<Proc:0x00005612ec70e090@-e:2> ...check link for more (https://carc.in/#/r/5v54)
[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:17] rubydoc: # => #<Proc:0x000055fac510cc80@-e:2> ...check link for more (https://carc.in/#/r/5v55)
[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: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:46:57] rubydoc: # => "is it main, or is it X?" ...check link for more (https://carc.in/#/r/5v57)
[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:13:18] phaul: but there are methods that the class receives and those are denoted with . in the documentation
[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: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:42] bathtub_shark: i mean, the former is too, but the latter is something i forgot to consider
[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:55:32] phaul: contracts here means the external interface (public methods) to something plus their promise on their behaviour.
[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.
[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: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: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:07:32] rubydoc: # => wrong argument type Class (expected Module) (TypeError) (https://carc.in/#/r/5v7n)