#ruby - 28 April 2018
« Back 1 day Forward 1 day »
[05:33:26] jsaak: Please share your thoughts about my feature request to ruby: buffer protocols https://www.reddit.com/r/ruby/comments/8fhxgw/ruby_feature_request_buffer_protocol/
[06:39:06] jsaak: > There is an article that describes the benefits quite well: https://jeffknupp.com/blog/2017/09/15/python-is-the-fastest-growing-programming-language-due-to-a-feature-youve-never-heard-of/
[06:46:32] ctooley: I am struggling with myArray.grep(). I have an array, it "seems" to be pretty straight forward... But, it only seems to one result instead of all 3
[06:49:17] elomatreb: ctooley: We'll be able to help you much better if you post your input and expected output, and current solution attempt
[06:49:58] ctooley: This code (https://pastebin.com/BP4wY2N5) is generating this output (https://pastebin.com/hgAXMMt0)
[06:51:54] elomatreb: It seems your search_pattern is a String. The semantics of === on String are just simple string equality (so you just filter the array for equal elements)
[06:52:16] elomatreb: (#grep filters an Enumerable using the === loose comparison method of the provided object)
[06:54:16] elomatreb: Assuming you want to filter for substrings, you could either transform the string to a regex (although I don't know how safe user-provided regex creation is, probably not very), or do a manual substring search
[06:56:25] elomatreb: Yeah, you're creating a regex. But you could e.g. artificially supply a hugely expensive regex which would impede your application
[07:02:57] ctooley: baweaver, elomatreb, Thanks again. I wouldn't think not doing ruby development for 2.5 years would have made me so rusty.
[10:06:16] hramrach: sadly the exception handling tutorials do not mention that to use the default handling you need your exception to be special
[10:09:53] hramrach: eg here https://ruby-doc.com/docs/ProgrammingRuby/html/tut_exceptions.html they make it look like rescue without type specification catches anything
[10:14:55] al2o3-cr: >> require 'fiddle'; include Fiddle; Pointer[dlwrap LoadError][8,4] = -Pointer[dlwrap StandardError]; require 'foo' rescue :hah
[10:23:19] hramrach: as it happens I am tryin to determine if I should load dl or fiddle so this does not solve the problem :p
[10:31:22] hramrach: there's nothing wrong with it except it does not work as described in the tutorial
[10:32:08] hramrach: the tutorial says rescue without type specification catches everything but it catches descendants of certain class only. These are common but not everyting.
[10:32:11] apeiros: hramrach: "If you write a rescue clause with no parameter list, the parameter defaults to StandardError"
[10:33:00] hramrach: maybe some other subsection other than "tidy Up" where the typeless rescue is given as example
[10:33:58] apeiros: it could be more explicit about not every exception inheriting from StandardError
[11:53:30] al2o3-cr: any particular reason for File.ftype for returning binary encoding string instead of utf-8?
[22:01:26] ruby[bot]: -bbb Dan_au477!*@*$#ruby-banned $a:gizmore$#ruby-banned gizmore!*@*$#ruby-banned