« Back to channel list

#ruby - 12 December 2018

« Back 1 day Forward 1 day »
[00:10:20] hutch: has joined #ruby
[00:11:40] bijan_: has joined #ruby
[00:15:43] bijan__: has joined #ruby
[00:16:48] jenrzzz: has joined #ruby
[00:20:57] d10n-work: has joined #ruby
[00:23:40] jenrzzz: has joined #ruby
[00:24:27] bijan_: has joined #ruby
[00:29:21] Koshian: has joined #ruby
[00:33:34] coderphive: has joined #ruby
[00:39:23] eckhardt_: has joined #ruby
[00:40:16] bijan_: has joined #ruby
[00:41:39] dviola: has joined #ruby
[00:51:53] jenrzzz: has joined #ruby
[00:52:23] bak1an: has joined #ruby
[01:01:49] bijan_: has joined #ruby
[01:04:33] crankharder: has joined #ruby
[01:05:28] carbone5: has joined #ruby
[01:06:18] jenrzzz: has joined #ruby
[01:09:03] cthulchu: has joined #ruby
[01:15:13] bijan_: has joined #ruby
[01:19:02] bijan__: has joined #ruby
[01:23:22] cthulchu: folks, can I do... a = {"qwe"=>{"a"=>1}}?
[01:23:27] cthulchu: put a hash into a hash
[01:23:47] cthulchu: essentially, do they have the same structure as json?
[01:26:21] carbone5: has joined #ruby
[01:28:11] bijan_: has joined #ruby
[01:30:44] smhuber: has joined #ruby
[01:32:20] smhuber: tldr; -9.pipe { abs | Math.sqrt | to_i } #=> 3
[01:32:22] smhuber: url.pipe { URI.parse | Net::HTTP.get | JSON.parse }
[01:32:46] bijan_: has joined #ruby
[01:32:59] smhuber: [9, 64].map(&Math.|.sqrt) #=> [3.0, 8.0]
[01:33:00] smhuber: [9, 64].map(&Math.|.sqrt.to_i.to_s) #=> ["3", "8"]
[01:33:07] cthulchu: what are you doing?
[01:33:28] smhuber: giving more context to my question above ^
[01:36:40] smhuber: if there's actually interest in something like that then I'll invest more time and port to C as a real feature request for Ruby
[01:36:55] bijan__: has joined #ruby
[01:39:57] carbone5: has joined #ruby
[01:42:14] al2o3-cr: smhuber: convince matz.
[01:43:41] Fr4n: has joined #ruby
[01:45:04] cthulchu: has joined #ruby
[01:45:11] bijan_: has joined #ruby
[01:46:03] baweaver: Considering how it conflicts with the regular pipe operator it probably won't happen. I know your code doesn't strictly touch it but that still overloads the operator which they're pretty touchy on
[01:47:06] smhuber: al2o3-cr attempting to here! https://bugs.ruby-lang.org/issues/13581#note-58
[01:48:39] smhuber: baweaver true although that's just an alias for syntactic sugar, the real method is __pipe__. I was curious and did take a look at the existing `|` definitions in the stdlib, looks like there's 10 and all of them expect an argument to be passed to it https://gist.github.com/shuber/b4d0a10c272d36f6b482ffd491e4cfba
[01:53:20] al2o3-cr: smhuber: personally i don't like the syntax.
[01:54:18] smhuber: does it feel confusing? too abstract?
[01:56:14] al2o3-cr: it's not confusing, just nah
[01:57:46] bijan_: has joined #ruby
[01:58:14] al2o3-cr: that's me though, others might agree.
[01:58:15] smhuber: ah ok gotcha - do you like the new proc composition and method reference operators that were proposed? the `<<` and `>>` and `map(&Method.:sqrt)`?
[01:59:43] carbone5: has joined #ruby
[01:59:49] kapil____: has joined #ruby
[02:00:20] al2o3-cr: smhuber: me personally, no.
[02:09:03] smhuber: al2o3-cr gotcha yea they always look a little strange at first but then end up growing on me lol, thanks for your feedback, much appreciated!
[02:10:24] bijan_: has joined #ruby
[02:11:35] al2o3-cr: smhuber: ruby should be simple, the way it was designed.
[02:15:47] uplime: has joined #ruby
[02:17:17] hutch: has joined #ruby
[02:18:02] smhuber: al2o3-cr maybe it was designed to be more "expressive" then "simple"? from https://www.ruby-lang.org/en/about/ - He [Matz] has often said that he is "trying to make Ruby natural, not simple," in a way that mirrors life. Building on this, he adds: Ruby is simple in appearance, but is very complex inside, just like our human body.
[02:18:32] cnsvc_: has joined #ruby
[02:21:39] al2o3-cr: smhuber: ok, so... foo | bar | baz is more expressive?
[02:22:13] smhuber: more natural in english - read left to right, no other visual noise like parens and temporary vars
[02:23:24] smhuber: check out what matz was exploring with https://github.com/matz/streem
[02:23:28] al2o3-cr: well i *don't* like it!
[02:23:56] al2o3-cr: smhuber: believe me i've seen it.
[02:26:26] smhuber: nice lol yea it's been around awhile :P - alrighty cool thanks again for the feedback!
[02:32:04] al2o3-cr: smhuber: why would you want this?
[02:35:27] al2o3-cr: smhuber: seriously?
[02:36:39] cliluw: has joined #ruby
[02:39:50] smhuber: al2o3-cr Oh lol I only made this just to prove it could be done - I got tired of reading comments like "Due to that any normal method call will be instantly evaluated so there is no way we will get syntax as nice as Elixir's pipe operator...". But once it was all said and done I thought the syntax felt pretty natural/elegant/concise and could possi
[02:39:50] smhuber: bly be a good fit as a core Ruby feature like it has been for many other languages
[02:40:36] smhuber: al2o3-cr my curiosity is completely satisfied - but if there is any interest in making this a real feature then I'll fork Ruby and put in the work, otherwise no big deal to me :P
[02:42:49] al2o3-cr: smhuber: go ahead, don't go just on my opinion. =)
[02:44:09] bijan_: has joined #ruby
[02:45:26] al2o3-cr: smhuber: i didn't like streems aproach tbh.
[02:57:16] al2o3-cr: and guilds...is a complex matter.
[02:57:19] bijan_: has joined #ruby
[03:05:30] crankharder: has joined #ruby
[03:06:09] smhuber: al2o3-cr - agreed - I didn't really like the idea of having to stream _all the time_ like that! I like Ruby style OOP method chaining - it already reads left to right which is very natural.
[03:06:26] smhuber: al2o3-cr The pipe syntax just feels handy when you need to call out to methods on other objects in chains like that - which in a world where things like decorators, presenters, and dependency inversion principles are popular - can happen pretty regularly
[03:09:15] al2o3-cr: smhuber: why spoil a good story by telling the truth?
[03:09:51] paranoicsan: has joined #ruby
[03:10:33] bijan_: has joined #ruby
[03:13:44] bambanxx: has joined #ruby
[03:14:48] bijan__: has joined #ruby
[03:23:20] bijan_: has joined #ruby
[03:32:39] bijan_: has joined #ruby
[03:46:08] bijan_: has joined #ruby
[03:50:53] bijan_: has joined #ruby
[03:50:55] arescorpio: has joined #ruby
[03:52:22] hutch: has joined #ruby
[03:55:21] bijan__: has joined #ruby
[03:55:33] jenrzzz: has joined #ruby
[03:55:58] dbz: has joined #ruby
[03:57:20] graphene: has joined #ruby
[03:59:33] dbz: has joined #ruby
[04:00:17] jhass: has joined #ruby
[04:00:52] jokke: has joined #ruby
[04:03:47] universa1: has joined #ruby
[04:05:51] Fusl: has joined #ruby
[04:10:32] braincrash: has joined #ruby
[04:11:35] horst: has joined #ruby
[04:11:54] carbone5: has joined #ruby
[04:16:11] tag: has joined #ruby
[04:37:34] bijan_: has joined #ruby
[04:38:11] bijan__: has joined #ruby
[04:46:07] sauvin: has joined #ruby
[04:47:55] Exuma: has joined #ruby
[04:50:13] bijan_: has joined #ruby
[04:55:32] marz_d`ghostman: has joined #ruby
[04:58:27] marz_d`ghostman: Is it possible in ruby to add an attribute to OpenStruct in rspec without retaining it like only inside a context scope? https://gist.github.com/marzdgzmn/47f733d18bb8da5feac2c5db89f200ea
[05:04:08] smhuber: marz_d`ghostman take a look at https://relishapp.com/rspec/rspec-core/v/2-2/docs/hooks/before-and-after-hooks - in your case it'd probably look something like https://gist.github.com/shuber/6564217aede7b70bf874b0baf3e50af8
[05:07:18] bijan_: has joined #ruby
[05:09:31] \void: has joined #ruby
[05:15:33] marz_d`ghostman: smhuber: thanks. Is there any blocks I can put an `allow` statement to be shared with multiple `it`s?
[05:16:00] Exuma: has joined #ruby
[05:16:42] smhuber: marz_d`ghostman should be able to put those in `before` blocks as well
[05:17:32] marz_d`ghostman: smhuber: so before blocks are local within context blocks eh?
[05:18:33] dbz: has joined #ruby
[05:20:03] thunderbirdtr: has joined #ruby
[05:20:07] smhuber: has joined #ruby
[05:23:18] akosednar: has joined #ruby
[05:23:32] segy: has joined #ruby
[05:25:08] smhuber: marz_d`ghostman they're only evaluated when running an "it" block that lives inside that context. there's different scopes though - ":all" vs ":each" vs ":suite" - there's more details/examples in https://relishapp.com/rspec/rspec-core/v/2-2/docs/hooks/before-and-after-hooks
[05:25:38] yasserhussain111: has joined #ruby
[05:27:40] hutch: has joined #ruby
[05:27:56] bijan_: has joined #ruby
[05:29:10] marz_d`ghostman: smhuber: Is there a book or a resource somewhere I can read to about these things? I didn't seem to ready any of it online
[05:30:50] houhoulis: has joined #ruby
[05:32:12] bijan__: has joined #ruby
[05:33:55] smhuber: marz_d`ghostman sure there's probably a bunch of books out there, I've definitely seen some on amazon. I think their online documentation has good examples though, I'd recommend just browsing thru that to get a nice overview of all the things it's capable of
[05:35:06] jenrzzz: has joined #ruby
[05:35:09] marz_d`ghostman: smhuber: okay thanks mate. I appreciate it :)
[05:35:30] smhuber: marz_d`ghostman happy to help!
[05:36:06] bijan_: has joined #ruby
[05:39:40] bijan__: has joined #ruby
[05:40:57] cnsvc_: has joined #ruby
[05:45:56] paranoicsan: has joined #ruby
[05:49:25] jenrzzz: has joined #ruby
[05:52:26] bijan_: has joined #ruby
[05:53:55] lunarkitty7: has joined #ruby
[05:58:40] jenrzzz: has joined #ruby
[06:03:02] uplime: has joined #ruby
[06:05:38] bijan_: has joined #ruby
[06:08:04] baweaver: RubyConf Rundown - Part One: https://medium.com/@baweaver/rubyconf-rundown-pt-1-f64d35ddaefd
[06:08:12] baweaver: Going to start going through the other videos soon
[06:09:28] bijan__: has joined #ruby
[06:16:51] aupadhye: has joined #ruby
[06:17:57] bijan_: has joined #ruby
[06:22:18] Cthulu201: has joined #ruby
[06:22:42] bijan__: has joined #ruby
[06:24:51] jenrzzz: has joined #ruby
[06:27:20] conta: has joined #ruby
[06:31:08] bijan_: has joined #ruby
[06:35:47] bijan_: has joined #ruby
[06:36:07] DarthGandalf: has joined #ruby
[06:39:41] maufart__: has joined #ruby
[06:44:08] bijan_: has joined #ruby
[06:48:24] bijan__: has joined #ruby
[06:50:11] reber: has joined #ruby
[06:56:38] bijan_: has joined #ruby
[07:09:48] bijan_: has joined #ruby
[07:10:13] cnsvc_: has joined #ruby
[07:12:49] ruby[bot]: -bb sonofentropy!*@*$#ruby-fix-your-connection *!*@84-10-10-170.static.chello.pl$#ruby-fix-your-connection
[07:13:51] graphene: has joined #ruby
[07:18:14] bijan_: has joined #ruby
[07:19:50] sonofentropy: has joined #ruby
[07:21:57] bijan__: has joined #ruby
[07:29:51] PaulePanter: has joined #ruby
[07:34:39] bijan_: has joined #ruby
[07:39:00] jenrzzz: has joined #ruby
[07:40:01] armyriad: has joined #ruby
[07:43:27] bijan_: has joined #ruby
[07:47:42] bijan__: has joined #ruby
[07:51:48] pbodev1: has joined #ruby
[07:51:54] bijan_: has joined #ruby
[07:52:05] pbodev1: has joined #ruby
[07:52:19] pbodev1: has joined #ruby
[07:52:33] pbodev1: has joined #ruby
[07:52:47] pbodev1: has joined #ruby
[07:53:10] pbodev1: has joined #ruby
[07:53:34] pbodev1: has joined #ruby
[07:53:55] pbodev1: has joined #ruby
[07:55:58] neuraload: has joined #ruby
[07:56:49] roshanavand: has joined #ruby
[08:00:14] bijan_: has joined #ruby
[08:01:17] pbodev1: has joined #ruby
[08:04:08] jenrzzz: has joined #ruby
[08:06:52] clemens3: has joined #ruby
[08:08:21] bijan_: has joined #ruby
[08:10:30] yasserhussain111: has joined #ruby
[08:11:17] yasserhussain111: has left #ruby: ()
[08:12:01] cnsvc_: has joined #ruby
[08:12:47] bijan__: has joined #ruby
[08:17:38] jenrzzz: has joined #ruby
[08:19:23] Renich: has joined #ruby
[08:20:26] Renich: has joined #ruby
[08:25:43] jsc: has joined #ruby
[08:26:11] cnsvc_: has joined #ruby
[08:31:19] burgestrand: has joined #ruby
[08:32:21] cnsvc_: has joined #ruby
[08:32:34] cheeti: has joined #ruby
[08:32:40] cheeti: in c before calling fprintf need to check fopen success
[08:38:37] jenrzzz: has joined #ruby
[08:38:45] cnsvc_: has joined #ruby
[08:39:40] Mike11: has joined #ruby
[08:42:54] powerbit: has joined #ruby
[08:45:45] ellcs: has joined #ruby
[08:45:54] jmcgnh: has joined #ruby
[08:47:20] jenrzzz: has joined #ruby
[08:55:55] jenrzzz: has joined #ruby
[09:00:31] yasserhussain111: has joined #ruby
[09:01:12] yasserhussain111: has joined #ruby
[09:01:56] yasserhussain111: has left #ruby: ()
[09:02:35] ur5us: has joined #ruby
[09:02:58] yasserhussain111: has joined #ruby
[09:07:16] za1b1tsu: has joined #ruby
[09:15:36] dbz: has joined #ruby
[09:17:12] jenrzzz: has joined #ruby
[09:34:22] jenrzzz: has joined #ruby
[09:34:28] neuraload: has joined #ruby
[09:42:05] yasserhussain111: has joined #ruby
[09:45:56] Nicmavr: has joined #ruby
[09:47:26] gregf_: has joined #ruby
[09:47:32] cnsvc_: has joined #ruby
[09:49:33] Guest61854: has joined #ruby
[09:53:03] adlerdias: has joined #ruby
[10:01:22] dhollin3: has joined #ruby
[10:04:20] AJA4350: has joined #ruby
[10:12:07] jenrzzz: has joined #ruby
[10:16:53] shangul: has joined #ruby
[10:21:24] ElFerna: has joined #ruby
[10:31:30] moei: has joined #ruby
[10:35:22] keden: has joined #ruby
[10:35:49] lucasb: has joined #ruby
[10:36:20] gheegh: has joined #ruby
[10:39:35] phaul: has joined #ruby
[10:44:37] DTZUZO: has joined #ruby
[10:48:38] brandonkal: has joined #ruby
[10:54:28] conta: has joined #ruby
[11:03:03] jenrzzz: has joined #ruby
[11:14:33] jenrzzz: has joined #ruby
[11:17:04] dbz: has joined #ruby
[11:18:24] cnsvc_: has joined #ruby
[11:20:25] kapil____: has joined #ruby
[11:23:03] ElFerna: has joined #ruby
[11:32:20] marz_d`ghostman: has joined #ruby
[11:36:32] ua: has joined #ruby
[11:36:33] marz_d`ghostman: How do I temporarily override a variable inside a context? It seems that the `before` statement on line 98 is overriding the statement and making the succeeding tests fail as it should have the value 'true' when getting out of that context: https://gist.github.com/marzdgzmn/fe94064b777c084aa4ef0284f0a46290
[11:46:22] donofrio: has joined #ruby
[11:50:26] maufart__: has joined #ruby
[11:54:20] jenrzzz: has joined #ruby
[11:54:31] conta: has joined #ruby
[11:58:55] jhass: marz_d`ghostman: it seems you're still confused as to when code inside a context/describe block vs when code inside a before/it/let block is run
[11:59:04] jhass: I suggest you think about and review that
[11:59:20] neuraload: has joined #ruby
[11:59:45] jhass: try with a blank spec file and putting puts statement to confirm the order of execution that you think there is
[12:01:51] neuraload: has joined #ruby
[12:05:24] neuraload: has joined #ruby
[12:07:14] neuraload: has joined #ruby
[12:10:35] paranoicsan: has joined #ruby
[12:12:10] neuraload: has joined #ruby
[12:12:17] marz_d`ghostman: jhass: I understand before statements on the outer context gets executed first before the before statements in an inner context. However, is there like a mechanism where the overriding variable will be local to the inner context like defining a local block variable e.g. ;x?
[12:13:36] jhass: you could probably do exactly that, but it would be quite confusing to most over just consistently using let
[12:15:17] sonofentropy: has joined #ruby
[12:17:46] sonofentropy: has joined #ruby
[12:18:06] GodFather: has joined #ruby
[12:19:13] x0F: has joined #ruby
[12:20:47] marz_d`ghostman: jhass: Uhhm, so like use let to define a new variable on every context? that was the next step I was thinking to do, just wondering if I can do it with a similar local block variable mechanism. Guess I got into it too deep though hehe
[12:21:02] sonofentropy: has joined #ruby
[12:21:36] jhass: inner contexts and before blocks there can of course access let definitions of outer ones
[12:21:58] jhass: btw describe and context are technically just aliases, don't worry about differences there
[12:22:48] jhass: another scheme is to use @instance_vars in before blocks, but most people prefer let these days for its cleaner looks and lazy evaluation
[12:24:35] ElFerna: has joined #ruby
[12:29:04] yasserhussain111: has joined #ruby
[12:31:14] marz_d`ghostman: jhass: So what I've though is to define a base object on the outer most via `let`. Then just extend that object and assign it to another variable via another `let` on inner context to preserve the base object for another inner context to use. Am I doing it right though?
[12:32:08] jhass: there's no general answer to that
[12:32:32] nickjj: has joined #ruby
[12:33:18] marz_d`ghostman: Okay, guess I'll just do that cause if I modify the variable defined by the outermost let in an inner context it seems to retain the modified value. Which seems to be what should be though now that I think of it :)
[12:33:41] jenrzzz: has joined #ruby
[12:34:11] jhass: yes, let's throw away their value after each example
[12:36:06] Fusl: has joined #ruby
[12:37:58] marz_d`ghostman: jhass: So it would be something like this: https://gist.github.com/marzdgzmn/a4ecd1abdf985d300147d7d4848feeed?
[12:38:36] jhass: you're still confused as to when code inside context/describe vs code inside let/before/it is run
[12:39:02] neuraload: has joined #ruby
[12:39:20] marz_d`ghostman: jhass: can you give me an example please
[12:39:36] maufart__: has joined #ruby
[12:46:02] jhass: https://p.jhass.eu/76.rb
[12:46:11] jhass: marz_d`ghostman: ^
[12:47:29] jenrzzz: has joined #ruby
[12:49:20] cnsvc_: has joined #ruby
[12:49:32] bak1an: has joined #ruby
[12:55:20] gheegh: has joined #ruby
[12:57:02] jenrzzz: has joined #ruby
[12:57:20] marz_d`ghostman: jhass: thanks, kudos to the test. I'm still currently going through it :)
[12:57:49] jhass: oh, useful flag for rspec there might also be -f d
[12:59:56] marz_d`ghostman: jhass: what's --seed 0 or --order rand:123 for?
[13:00:17] jhass: rspec by default randomizes the order in which it runs your example
[13:00:22] jhass: *examples
[13:00:26] graphene: has joined #ruby
[13:00:32] jhass: -seed gives a deterministic ordering
[13:02:46] reber: has joined #ruby
[13:04:03] marz_d`ghostman: I'm starting to understand it better now. So ruby evaluates the code like in two phases, once for none test-related stuff hence 'ABFJK', then second for the test-related stuff starting with the `before` statement going to the `it` while lazily evaluates any `let` definitions
[13:09:20] jenrzzz: has joined #ruby
[13:15:59] roshanavand: has joined #ruby
[13:19:55] keden: has joined #ruby
[13:21:10] jhass: now looking it --order defined is maybe the nicer option here to achieve that :D
[13:21:37] jenrzzz: has joined #ruby
[13:23:12] marz_d`ghostman: it still gives the same output though, am just gonna save this code for future reference, really appreciate you clearing me from my confusion mate. thanks
[13:33:45] jenrzzz: has joined #ruby
[13:45:55] dmitch: has joined #ruby
[13:49:18] mostlybadfly: has joined #ruby
[13:49:49] crankharder: has joined #ruby
[13:52:41] paranoicsan: has joined #ruby
[13:54:09] jenrzzz: has joined #ruby
[14:09:07] awkwords: has joined #ruby
[14:09:12] Puffball: has joined #ruby
[14:12:49] kapil____: has joined #ruby
[14:18:19] hutch: has joined #ruby
[14:18:30] cnsvc_: has joined #ruby
[14:27:40] Fr4n: has joined #ruby
[14:29:01] horst_: has joined #ruby
[14:33:20] rubydoc: has joined #ruby
[14:41:16] jenrzzz: has joined #ruby
[14:45:10] sonofentropy: has joined #ruby
[14:47:41] phaul: has joined #ruby
[14:53:10] rippa: has joined #ruby
[14:55:55] ElFerna: has joined #ruby
[14:58:31] Guest61854: has joined #ruby
[15:04:07] paranoicsan: has joined #ruby
[15:08:11] krawchyk: has joined #ruby
[15:09:50] hutch: has joined #ruby
[15:11:42] jenrzzz: has joined #ruby
[15:20:00] neuraload: has joined #ruby
[15:20:14] graphene: has joined #ruby
[15:22:47] paranoicsan: has joined #ruby
[15:24:09] polishdub: has joined #ruby
[15:28:37] wlan2: has joined #ruby
[15:31:44] wlan2: So I was returning to the koans after some time off them due to work. I find myself stranded in the face of about_scoring_project.rb with a big doubt.
[15:31:51] sonofentropy: has joined #ruby
[15:32:22] wlan2: Should I restart the koans instead of trying to finish them?
[15:34:08] wlan2: I also don't know if there's a better place to ask.
[15:36:13] jenrzzz: has joined #ruby
[15:36:40] Inside: I always found the koans a bit of a strange way to approach learning programming
[15:37:51] Inside: these are a bit different than what I was thinking of
[15:38:57] Inside: I guess it depends on what your question is
[15:39:01] Inside: what are you exactly stuck on
[15:39:17] Inline: has joined #ruby
[15:40:03] Inside: I'm looking at someone's solution for this specific test file and there is nothing language specific in there
[15:40:08] Inside: it's 100% logic
[15:41:25] SuperLag: has joined #ruby
[15:43:17] venmx: has joined #ruby
[15:44:34] wlan2: Well I am 100% sure that I can do it with a crapload of if. And also completely sure I don't want to write a crapload of if nor do I want to copy someone else's solution.
[15:45:59] hutch: has joined #ruby
[15:46:28] Inside: blah blah green, red, refactor
[15:46:55] wlan2: Well I guess that's true...
[15:47:01] Inside: https://github.com/edgecase/ruby_koans/blob/master/src/GREED_RULES.txt
[15:47:16] Inside: are you able to pass the first test?
[15:47:19] Inside: what test are you stuck on?
[15:48:40] cnsvc_: has joined #ruby
[15:49:14] zapata: has joined #ruby
[15:49:26] wlan2: koans/about_scoring_project.rb:76:in `test_score_of_a_triple_1_is_1000
[15:49:56] conta: has joined #ruby
[15:50:11] Inside: do you have a specific question or are you just *stuck*
[15:50:20] Inside: ie: you don't even know how to approach it?
[15:52:28] wlan2: I'm not sure how to approach it. up until now I put a for with a couple if inside.
[15:52:29] jenrzzz: has joined #ruby
[15:53:14] Inside: in ruby an array is subclassed from 'enumerable'
[15:53:25] Inside: which has a count function
[15:53:29] Inside: https://ruby-doc.org/core-2.5.3/Enumerable.html#method-i-count
[15:53:51] Inside: you could write your own count() function, or you could use the built in one
[15:54:38] Inside: One of ruby's greatest features is the HUGE standard library which comes with functions for almost every data manipulation you can think of
[15:54:45] Inside: (unlike say... javascript which basically comes with nothing)
[15:56:33] wlan2: I didn't realize count accepted parameters!
[15:56:51] wlan2: Thank you.
[15:56:52] Inside: it also accepts a block ^_^
[15:56:58] Inside: BRB an hour or so -meeting :|
[15:58:08] phaul: nitpick, for sake of correctness... Enumerable is a module, and Array includes it, not subclasses.
[16:00:00] wlan2: I'm still unsure about what is and isn't a module in ruby.
[16:01:18] phaul: it's a bit nebulous, but if you can give of concrete instance examples that implies class. Usually if there are no instances it's module
[16:01:44] phaul: there is [1,2,3] an Array, so Array has to be class. There is no concrete instance of an Enumerable
[16:03:53] wlan2: Well I'll take this as an iI should make another cup of tea and use that sexy count method (or was it function?)
[16:05:46] phaul: method. everything is a method including module_function :)
[16:05:53] phaul: &ri module_function
[16:05:53] rubydoc: https://ruby-doc.org/core-2.5.3/Module.html#method-i-module_function
[16:08:54] wlan2: In case of doubt, everything is a Nyarlatoteph avatar.
[16:18:28] Moeh: has joined #ruby
[16:20:03] Moeh: Hi! In my ruby app I'd like to create a class called "File" which should not 'override' the default Ruby File class. Is there a way to access the default Ruby File class within my app using something like Ruby::File (which doesn't work). Or inherit from the default Ruby File class using something like "class File < File # inherits from Ruby File class" (which also doesn't work).
[16:21:18] jenrzzz: has joined #ruby
[16:21:23] phaul: First I would put the entire APP in it's own namespace. Then nothing you do collide with anybody elses stuff, including gems, or stdlib
[16:21:51] phaul: then your file would become MyApp::File, while stdlib file is just File.
[16:22:43] akaiiro: has joined #ruby
[16:23:26] themsay: has joined #ruby
[16:23:31] sonofentropy: has joined #ruby
[16:23:38] wlan2: has joined #ruby
[16:23:57] phaul: you can achive this by wrapping all your classes , modules inside module MyApp ... end in all your files
[16:25:39] cpruitt: has joined #ruby
[16:25:42] phaul: actually.. ::File for Ruby file.
[16:28:38] phaul: if you are inside MyApp. Moeh , does this make sense?
[16:30:05] Moeh: I am using https://github.com/davetron5000/gli to build a CLI and it looks like it already wraps everything in a "class App" which then loads modules. But it looks like inside of the class definition it'd refer to itself. So in: "module MyModule class File File.basename() end end" File actually refers to itself (and throws a method undefined error). However, when I use "::File" inside it refers to the stdlib and works.
[16:30:34] Moeh: Yes, thanks, makes sense! I'll use "::File" inside of the class definition and then everything works.
[16:32:00] Moeh: Outside of the class definition the names are correctly scoped, so if I do "File" outside of the definition I get the stdlib File and MyModule::File returns my own class as expected. Perfect, thanks a lot!
[16:34:11] doubledup: has joined #ruby
[16:45:17] Dbugger: has joined #ruby
[16:56:46] jenrzzz: has joined #ruby
[17:03:31] smhuber: has joined #ruby
[17:05:10] phaul: Moeh, if you are interested, there are some obscure pitfalls around this, namely the difference between module MyApp; class MyClass; end; end; vs class MyApp::MyClass; end. If you write the latter, and use File you don't need ::File, you can use File, but for the former you need the ::
[17:05:57] phaul: I explain why here https://github.com/phaul/ruby_101/blob/master/content/book.md#lexical-scope-nesting
[17:12:49] grantedbark78: has joined #ruby
[17:17:39] mikecmpbll: has joined #ruby
[17:17:58] graphene: has joined #ruby
[17:18:43] cnsvc_: has joined #ruby
[17:19:34] tag: has joined #ruby
[17:19:50] ElFerna: has joined #ruby
[17:22:53] Moeh: phaul: Great, thanks so much!
[17:27:00] adlerdias: has joined #ruby
[17:27:46] dbz: has joined #ruby
[17:27:55] sonofentropy: has joined #ruby
[17:29:41] dbz_: has joined #ruby
[17:30:35] dbz_: has joined #ruby
[17:31:16] themsay: has joined #ruby
[17:33:16] jenrzzz: has joined #ruby
[17:34:17] cthulchu_: has joined #ruby
[17:35:17] hutch: has joined #ruby
[17:36:23] cthu|: has joined #ruby
[17:39:32] code_zombie: has joined #ruby
[17:39:57] graphene: has joined #ruby
[17:41:42] graft: has joined #ruby
[17:43:37] graft: hey all, i often have trouble with the case statement when I'm trying to match a class, e.g., x = Float; case x; when Float;...;end
[17:44:03] graft: the behavior here is that the when Float does not match, because x is not a Float, it is a Class
[17:44:24] graft: is there any way to match this with case/when, or am i stuck with if/elsif?
[17:45:21] phaul: &>> x = 3.14; case x; when Float then 'yay'; else 'no cigar'; end
[17:45:22] rubydoc: # => "yay" (https://carc.in/#/r/5rw8)
[17:45:25] mikecmpbll: has joined #ruby
[17:46:14] graft: &>> x = Float; case x; when Float then 'yay'; else 'no cigar'; end
[17:46:15] rubydoc: # => "no cigar" (https://carc.in/#/r/5rw9)
[17:46:33] phaul: graft: depends on what you want. class implements === as being kind_of? . so ruby is right. Float is not kind of Float
[17:46:49] phaul: 3.14 is kind of float
[17:46:54] graft: sure, i understand what it's doing, i'm just wondering if there is a way around this behavior
[17:47:13] graft: i.e., some way to match Float == Float using when
[17:47:39] graft: i suspect not
[17:47:42] phaul: sure override Class ===
[17:48:01] graft: that would surely have no negative repercussions
[17:48:39] phaul: I agree it's a bit confusing that just beacuse a == b it's not necesarrily a === b
[17:49:17] millerti: has joined #ruby
[17:53:00] Inside: some might ask why you're doing a case on a class
[18:00:34] yokel: has joined #ruby
[18:03:33] phaul: graft, there is a boolean statement form of case, it's a bit like syntactic sugared if ... if else ..
[18:04:30] eckhardt_: has joined #ruby
[18:04:34] phaul: &>> case; when true then 'whoa'; when false then 'what?'; else 'no way'; end
[18:04:39] rubydoc: # => "whoa" (https://carc.in/#/r/5rwc)
[18:04:53] bambanx: has joined #ruby
[18:04:58] baweaver: phaul is on the case!
[18:05:16] phaul: ohai baweaver :)
[18:05:31] baweaver: ohai lunarkitty7
[18:06:00] baweaver: Case statements are fun to play with.
[18:06:09] baweaver: Especially after you grok ===
[18:06:28] phaul: yeah, and combine them with procs and stuff
[18:06:42] phaul: and you arrive at Qo ;)
[18:06:51] ogres: has joined #ruby
[18:06:54] lucasb: has joined #ruby
[18:06:59] baweaver: To be fair Qo uses === pretty religiously
[18:07:20] baweaver: Also if anyone's looking for some RubyConf videos to start with: https://medium.com/@baweaver/rubyconf-rundown-pt-1-f64d35ddaefd
[18:07:24] Sigfrid: has joined #ruby
[18:07:29] baweaver: Going through some other talks this weekend.
[18:08:02] baweaver: There's rumored to be pattern matching in Ruby 3.x
[18:08:07] baweaver: Though it may show up earlier
[18:08:19] baweaver: Dare we hope 2.7? We shall see
[18:08:47] gheegh: has joined #ruby
[18:12:54] graphene: has joined #ruby
[18:15:17] themsay: has joined #ruby
[18:17:12] slima: has joined #ruby
[18:23:19] Aqo: has joined #ruby
[18:23:46] themsay: has joined #ruby
[18:24:37] sonofentropy: has joined #ruby
[18:26:16] themsay: has joined #ruby
[18:38:50] slima: Hi, I try to use Nokogiri to parse xml and make changes for some values, But I completly lost, I have xml with structure: https://gist.github.com/slima/34d684fe3fd7dd016301a93a5782370d and I like to get values for first DictionaryEntry, but I can't: https://gist.github.com/slima/3828d66178c10be259b607648f64be89
[18:38:50] ElFerna: has joined #ruby
[18:40:48] jenrzzz: has joined #ruby
[18:45:10] gix: has joined #ruby
[18:54:08] themsay: has joined #ruby
[19:00:02] SuperLag: has joined #ruby
[19:12:38] themsay: has joined #ruby
[19:13:40] raulp: has joined #ruby
[19:14:08] al2o3-cr: slima: you just want the values from the first dictionary entry?
[19:15:49] themsay: has joined #ruby
[19:16:48] Paraxial: has joined #ruby
[19:17:22] lxsameer: has joined #ruby
[19:25:19] ElFerna: has joined #ruby
[19:25:49] weaksauce: has joined #ruby
[19:29:24] cow[moo]: has joined #ruby
[19:33:50] ElFerna: has joined #ruby
[19:40:24] GodFather: has joined #ruby
[19:41:37] Sigfrid: has joined #ruby
[19:46:52] venmx: has joined #ruby
[19:47:08] s3nd1v0g1us: has joined #ruby
[19:52:49] roshanavand: has joined #ruby
[19:58:56] jenrzzz: has joined #ruby
[19:59:22] evdubs: has joined #ruby
[20:03:53] GodFather: has joined #ruby
[20:14:32] cpruitt: has joined #ruby
[20:18:09] mr_blue: has joined #ruby
[20:19:46] mr_blue: something strange happen with dotenv gem. It the .env variable was bash exported, the gem does not load the .env file value
[20:22:38] cnsvc_: has joined #ruby
[20:23:24] ur5us: has joined #ruby
[20:25:13] carbone5: has joined #ruby
[20:33:18] mr_blue: in a rake task
[20:33:54] venmx: has joined #ruby
[20:36:56] mr_blue: my oneliner problem https://gist.github.com/884cb19e8e6e251de10690695da3b680
[20:38:26] serard: has joined #ruby
[20:39:00] mr_blue: my result https://gist.github.com/4f180b5a502ef0915be9343ca9156770
[20:39:16] sonofentropy: has joined #ruby
[20:39:40] Freshnuts: has joined #ruby
[20:44:08] bambanxx: has joined #ruby
[20:45:03] nowhere_man: has joined #ruby
[20:49:46] ElFerna: has joined #ruby
[20:53:18] venmx: has joined #ruby
[20:53:31] Guest61854: has joined #ruby
[20:56:49] slima: al2o3-cr: I like a modify a values like <ISP>, <VID> so: search for <VID></VID> in first DictionaryEntry and insert 3 for example
[20:58:32] ElFerna: has joined #ruby
[21:00:19] za1b1tsu: has joined #ruby
[21:00:21] al2o3-cr: slima: https://www.nokogiri.org/tutorials/modifying_an_html_xml_document.html
[21:00:48] StarLord__: has joined #ruby
[21:07:37] za1b1tsu: has joined #ruby
[21:07:52] serard_: has joined #ruby
[21:12:10] Sembei: has joined #ruby
[21:19:42] krawchyk: https://rubocop.readthedocs.io/en/latest/cops_performance/#performancechainarrayallocation
[21:20:07] krawchyk: does this mean `Enumerable#each_with_object` is more performant than `reduce` or `inject`?
[21:20:48] krawchyk: because each_with_object doesnt instantiate new accumulator objects each iteration
[21:20:59] krawchyk: or do i need to read up on my Ruby internals?
[21:21:37] havenwood: krawchyk: reduce/inject also have a persistent accumulator that's being mutated - just like each_with_object
[21:22:36] havenwood: krawchyk: there are various performance and memory implications of having frozen arrays non-mutating methods versus unfroze arrays that mutate
[21:22:54] havenwood: krawchyk: i'd not take this tweet-based cop with too much seriousness :P
[21:23:35] havenwood: krawchyk: i'd suggest that you do your own benchmarking and check the actual memory and performance implications for your case
[21:25:15] havenwood: krawchyk: I did a PR a long time ago that changed Rails to use mutating methods. It was eventually rejected with a shrug.
[21:25:16] havenwood: krawchyk: There's something nice about functional methods.
[21:26:36] havenwood: krawchyk: an aside, but tenderlove just proposed a commit for Ruby that would allow for a frozen_hash_and_array_literal magic comment.
[21:26:50] slima: al2o3-cr: yeah, I read that, but this examples is not clear to me.
[21:26:56] havenwood: krawchyk: frozen arrays wouldn't work with map!, etc.
[21:27:30] havenwood: (I do think frozen_hash_literal should probably be separate from frozen_array_literal with a catch-all frozen_literals.)
[21:28:57] SeepingN: has joined #ruby
[21:31:35] cow[moo]: has joined #ruby
[21:34:20] al2o3-cr: slima: `doc.at_xpath("//vid").content = "whatever"'
[21:35:35] krawchyk: interesting, thanks for the comprehensive explanation havenwood
[21:37:32] al2o3-cr: slima: changing an attribute doc.at_xpath("//key").attribute("classname").value = "i am now something else"
[21:40:36] slima: al2o3-cr: ok, tommorow I will try one more time ;) thanks you
[21:45:12] Guest61854: has joined #ruby
[21:49:44] darkhanb: has joined #ruby
[21:50:23] Renich: has joined #ruby
[21:51:41] cthulchu_: has joined #ruby
[21:52:08] Sigfrid: has joined #ruby
[21:53:00] powerbit: has joined #ruby
[21:53:21] powerbit: has joined #ruby
[21:53:40] powerbit: has joined #ruby
[21:56:06] powerbit: has joined #ruby
[21:59:13] weaksauce: has joined #ruby
[22:01:22] powerbit: has joined #ruby
[22:03:20] hutch: has joined #ruby
[22:21:33] profetes_: has joined #ruby
[22:23:40] tycoon177_: has joined #ruby
[22:25:13] PasNox_: has joined #ruby
[22:28:13] \void: has joined #ruby
[22:29:07] Ca1us: has joined #ruby
[22:29:44] TheTFEF: has joined #ruby
[22:29:44] EvilJStoker: has joined #ruby
[22:30:14] Sigfrid: has joined #ruby
[22:30:59] lunarkitty7: has joined #ruby
[22:31:02] Demos[m]: has joined #ruby
[22:31:26] bathtub_shark: has joined #ruby
[22:32:53] devyn: has joined #ruby
[22:34:40] irdr: has joined #ruby
[22:38:59] cd: has joined #ruby
[22:39:00] wnd: has joined #ruby
[23:00:36] ruby[bot]: has joined #ruby
[23:00:36] ChanServ: +o ruby[bot]
[23:09:55] graphene: has joined #ruby
[23:10:13] Ookma-Kyi: has joined #ruby
[23:10:25] Ookma-Kyi: Help: http://i65.tinypic.com/sg22ig.jpg
[23:24:31] cow[moo]: has joined #ruby
[23:27:30] ElFerna: has joined #ruby
[23:31:29] phaul: Ookma-Kyi in the future try pasting error logs / code on dpaste.de or gist.github.com etc. Flashing animated gifs with jpeg screenshots of screen contents are not going to be popular with people trying to help.
[23:32:28] phaul: Also try to explain what you are doing, unless someone has seen the exact same backtrace it's unlikely that anybody could help
[23:35:00] SeepingN: has joined #ruby
[23:35:52] ruby[bot]: How to ask the right questions to get you the right answer: https://www.mikeash.com/getting_answers.html
[23:36:02] ElFerna: has joined #ruby
[23:36:53] ElFerna: has joined #ruby
[23:36:55] miah: would also help to provide the failing code if possible
[23:41:46] ElFerna: has joined #ruby
[23:42:40] Hobbyboy|BNC: has joined #ruby
[23:43:36] cnsvc_: has joined #ruby
[23:50:46] ElFerna: has joined #ruby
[23:54:54] ElFerna: has joined #ruby