#ruby - 07 December 2018
« Back 1 day Forward 1 day »
[00:03:49] lucasb: which formats the tarball are available? :) https://www.ruby-lang.org/en/news/2018/12/06/ruby-2-6-0-rc1-released/
[00:09:52] lucasb: havenwood: https://github.com/ruby/www.ruby-lang.org/commit/aae76c9f90e6d98fe4d4160192cd6b5ef1da382a
[03:04:30] havenwood: From a Ruby perspective it sounds right. Usually I say "Ruby and Rails" instead of "Ruby and Ruby on Rails"
[08:33:26] makara: @baweaver, I think I understand now. +- is not an operator, so I can't overload it. I was wanting to create a new operator, but i don't see how the Ruby parser would understand how to tokenize it in the first place
[08:35:34] baweaver: Then I'd focus on learning basics instead of trying to get too much into that type of thing quite yet.
[10:02:43] ruby[bot]: slowmow: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
[10:06:07] phaul: Im guessing you have to fill in 'path' with actual value rather than passing the literal value '/path'
[10:25:52] phaul: but the previous link doesn't work any more, so I can't see the error and code together ...
[10:26:49] slowmow: pipal.rb:184:in `realpath': No such file or directory @ realpath_rec - /path (Errno::ENOENT)
[11:04:22] lucasb: look at the size of the that word :) I guess they didn't wanted just "RubyVM::AST"
[11:08:20] lucasb: it seems it was AST before... https://github.com/ruby/ruby/commit/1d7d08262e07b7d0d11ec2d4efa29ad2b52c565a
[11:08:41] lucasb: IMO shorter names are better. anyway, just a detail I spotted on the RC1 announcement
[15:28:08] JjOtt: ruby(36489,0x1030375c0) malloc: *** error for object 0x7fca5c06a0f8: pointer being freed was not allocated
[15:28:09] JjOtt: ruby(36489,0x1030375c0) malloc: *** set a breakpoint in malloc_error_break to debug
[15:33:11] blood: How do I prevent ruby from resolving environment variables passed to shell execute? If I run my script manually, everything works as expected
[16:01:31] havenwood: lucasb: The switch to AbstractSyntaxTree was for parity with InstructionSequence.
[19:34:50] knight33: This question might be a little abstract, but where to begin writing an application? I've no issue looking at other Ruby applications, and understanding the majority of code, conditionals, variables, scopes, objects, etc. I've fixed so many bugs at work. However, when I sit and stare at a blank terminal in Vim, trying to write an API or web app or
[19:34:50] knight33: something, I don't know what to do. I keep finding tutorials on Rails that teach you how to generate controllers and skip the learning part. Any suggestions?
[20:33:17] Scriptonaut: hey I was just wondering if any of you know an array method similar to .find, but rather than returning the first element that satisfies the condition, it returns a property/value of that element. So like if I had an array of object, I would want to return object.some_value of the first object that satisfies the condition, rather than returning the object itself
[20:33:49] Scriptonaut: I could easily do this in two lines, but I'm wondering if there's a shorthand oneliner way
[20:34:42] Scriptonaut: actually I might just change it to an each loop and then return the element explicitly, I just usually liek to avoid explicit return statements when it's at the tail-end of a method
[20:37:19] Scriptonaut: I could do `next if blah?` and then chain a `compact` to the end of the block but that would be janky
[20:39:08] Scriptonaut: I need a method like find, but rather than returning the element, it returns a result I calculate in the block
[20:50:48] Scriptonaut: find returns the element in the array, not a different value calculated from the element
[20:51:13] woodruffw: right, i'm saying that you should return the element and then chain the calculation after it
[20:51:51] Scriptonaut: I need the calculation in order to determine if it satisfies the condition, which is an expensive database lookup, I don't want to have to do that calculation twice. I think I'm just going to do an each loop and do an explicit return
[20:52:52] havenwood: Scriptonaut: Have you tried just selecting them mapping? Does that incur a penalty in your case?
[20:53:34] Scriptonaut: selecting then mapping would incur a penalty because then the alg would become 2n rather than n (O)
[20:54:31] Scriptonaut: Eiam: because I'm looping over an array of object, then doing a db lookup for each one, then determining if the lookup yielded a sufficient result. If it did, then I need to return that result
[20:54:45] Scriptonaut: so I would have to calculate the result a second time once I returned teh element
[20:54:55] Eiam: why not get array of object, get all data and do a single lookup, then filter that?
[20:55:42] Eiam: you are paying the price of an array of unknown size DB lookups one at a time but if you've already got the data..
[21:05:57] havenwood: Scriptonaut: FWIW, #select_map is easy to implement: https://gist.github.com/havenwood/4fdea01e423b96c5457fc959f33cfc08
[21:15:17] Scriptonaut: ya, true, that's a decent solution, though I'd have to tack a .first on the end of it
[21:22:12] havenwood: Scriptonaut: (This is why we don't implement these all. They're too custom. Elixir deprecated select_map for that reason iir.)
[21:27:49] Scriptonaut: I use break all the time, but I didn't know if you passed it a value it would break from the block and return that value
[21:28:48] havenwood: Scriptonaut: fixed it to return `nil` instead of the receiver if nothing found
[21:31:08] havenwood: Scriptonaut: I do contribute to a couple implementations of Ruby, as a hobbyist not core of anything.
[21:36:51] Scriptonaut: havenwood: nice. You mixed up the dx_code.code and dx_code.code_type in the else statement, but I like that idea better than mine (having an assignment operation inside a conditional)