« Back to channel list

#ruby - 08 March 2019

« Back 1 day Forward 1 day »
[00:00:30] bjpenn: any ruby ninja techniques to get it to do what i want? :P
[00:00:51] bjpenn: the reason being, the contents within the heredoc, the "string", is a complex regex expression
[00:00:58] bjpenn: i want to keep the essence of that the way it is copy/pasted
[00:01:06] bjpenn: the only thing that needs changing is "\" being "\\"
[00:01:27] bjpenn: and some fields that will become string interpolated like this: #{blah}
[00:02:31] mozzarella: are you going to create a regex object with said string? is it a valid ruby regex?
[00:04:29] bjpenn: its actuallynot regex
[00:04:36] bjpenn: its a query string for sumologic
[00:04:44] bjpenn: it contains regex though
[00:04:59] bjpenn: but i prefer the whole thing to be in a heredoc
[00:05:21] bjpenn: without me going to random characters and escaping them manually
[00:06:36] mozzarella: bjpenn: you could do something like this: https://www.honeybadger.io/blog/data-and-end-in-ruby/
[00:06:57] havenwood: bjpenn: how about heredoc with sprintf?
[00:07:13] mozzarella: erb template at the end of the file
[00:07:31] leftylink: a study of https://ruby-doc.org/core-2.5.0/doc/syntax/literals_rdoc.html#label-Here+Documents reveals that IF this is using a literal, the only option is to disable *both* interpolation and escaping, with no option to only disable escaping while keeping interpolation. so the solution will have to be something other than a literla.
[00:08:29] havenwood: bjpenn: https://gist.github.com/havenwood/e867b667b35630ed9a9907225137bded
[00:08:43] havenwood: bjpenn: <<~'END' % {meaning: 42}
[00:09:20] mozzarella: I think I prefer this way, actually
[00:11:07] bjpenn: looking..
[00:11:49] bjpenn: nice... that might actually work
[00:12:13] bjpenn: im using heredocs as part of an erb template though
[00:12:18] bjpenn: ACTION crosses fingers
[00:12:19] bjpenn: trying it
[00:14:40] ubuntuisloved: has joined #ruby
[00:17:32] mozzarella: bjpenn: can't it be its own template, then, and then embedded in the parent template?
[00:17:38] mozzarella: shouldn't be too hard
[00:18:12] bjpenn: yeah i suppose that would work too
[00:19:11] nowhereman: has joined #ruby
[00:19:22] bjpenn: that ruby magic didnt bode well with the erb
[00:19:37] bjpenn: thank you all for trying though! :)
[00:23:38] havenwood: fun with ERB templates!
[00:23:57] havenwood: it's interesting that Ruby's JIT uses ERB :)
[00:25:06] havenwood: here's a simple ERB template i meant to do a writeup on to introduce folk to making their own templates: https://gist.github.com/havenwood/4469e3975ce0b597e00a3cf205dea4bb
[00:27:42] blackmesa: has joined #ruby
[00:34:41] AJA4350: has joined #ruby
[00:37:16] DeadPixelz01: has joined #ruby
[00:37:58] orbyt_: has joined #ruby
[00:45:28] crankharder: has joined #ruby
[00:56:32] dviola: has joined #ruby
[01:03:43] conta: has joined #ruby
[01:06:50] orbyt_: has joined #ruby
[01:13:43] Swyper: has joined #ruby
[01:14:40] sidepocket: has joined #ruby
[01:17:24] bambanx: has joined #ruby
[01:38:09] Renich: has joined #ruby
[01:38:49] Averna: has joined #ruby
[01:39:12] r29v: has joined #ruby
[01:42:34] r29v: has joined #ruby
[01:46:02] mjacob: is there a builtin (or shorter / more idiomatic) version of "Enumerator.new do |y| loop do y << f() end end.lazy"?
[01:48:58] mangold: has joined #ruby
[01:55:54] FastJack: has joined #ruby
[02:06:02] Swyper: has joined #ruby
[02:07:21] sgen: has joined #ruby
[02:14:27] Swyper: has joined #ruby
[02:19:50] Swyper: has joined #ruby
[02:20:16] Onwarion: has joined #ruby
[02:35:34] havenwood: mjacob: that reminds me of Elixir's Stream.repeatedly/1, which you can implement just like you showed: https://github.com/havenwood/elixir.rb/blob/master/lib/elixir/stream.rb#L29-L35
[02:36:35] havenwood: mjacob: https://gist.github.com/havenwood/40d3ae8acc87257624012b975816780e
[02:36:37] mjacob: i agree that we all should use (better) functional languages, but i don't really have a choice ;)
[02:36:59] havenwood: mjacob: You could make a helper method like ^ and then: repeatedly { foo }.lazy
[02:50:59] crankharder: has joined #ruby
[02:53:15] ozzloy: has joined #ruby
[02:53:15] ozzloy: has joined #ruby
[03:01:22] sacomo: has joined #ruby
[03:01:47] Swyper: has joined #ruby
[03:10:42] v01d4lph4: has joined #ruby
[03:11:58] Renich_: has joined #ruby
[03:19:29] Tau: has joined #ruby
[03:22:23] aqd_: has joined #ruby
[03:23:25] Tempesta_: has joined #ruby
[03:24:49] miah: has joined #ruby
[03:25:13] cd: has joined #ruby
[03:31:34] Tempesta_: has left #ruby: ("Closing Channel, bye.")
[03:31:43] Tempesta: has joined #ruby
[03:59:28] duderonomy: has joined #ruby
[04:00:40] fluxAeon: has joined #ruby
[04:03:26] DTZUZO: has joined #ruby
[04:04:43] v01d4lph4: has joined #ruby
[04:09:45] braincrash: has joined #ruby
[04:13:11] crankharder: has joined #ruby
[04:24:51] Nicmavr: has joined #ruby
[04:28:21] BTRE: has joined #ruby
[04:37:55] Swyper: has joined #ruby
[04:41:59] ur5us: has joined #ruby
[04:44:36] v01d4lph4: has joined #ruby
[04:48:27] DeadPixelz01: has joined #ruby
[04:57:43] sgen: has joined #ruby
[04:59:51] Fusl: has joined #ruby
[05:02:24] RiPuk: has joined #ruby
[05:05:42] crankharder: has joined #ruby
[05:12:47] jud: has joined #ruby
[05:12:47] jud: has joined #ruby
[05:15:04] crankharder: has joined #ruby
[05:16:17] Calinou: has joined #ruby
[05:19:49] rippa: has joined #ruby
[05:19:49] jmcgnh_: has joined #ruby
[05:26:17] Swyper: has joined #ruby
[05:53:13] Swyper: has joined #ruby
[05:55:38] aqd: has joined #ruby
[06:08:29] SeepingN: has joined #ruby
[06:10:14] evdubs_: has joined #ruby
[06:17:10] Renich: has joined #ruby
[06:19:14] bambanx: has joined #ruby
[06:21:19] conta: has joined #ruby
[06:25:55] crankharder: has joined #ruby
[06:44:11] aufi: has joined #ruby
[06:50:10] tdy: has joined #ruby
[06:55:13] reber: has joined #ruby
[06:56:33] laaron: has joined #ruby
[06:59:13] eightfold: has joined #ruby
[07:08:28] qual: has joined #ruby
[07:08:49] sagax: who use vim - what the best colorscheme for ruby?
[07:10:30] skryking: has joined #ruby
[07:13:10] jane_booty_doe: has joined #ruby
[07:21:04] fluxAeon: has joined #ruby
[07:21:50] crankharder: has joined #ruby
[07:22:54] t0xik: has joined #ruby
[07:38:17] DaRock: has joined #ruby
[07:41:56] bambanx: hi sagax ! i use vim
[07:42:50] hahuang6-: has joined #ruby
[07:45:11] ur5us: has joined #ruby
[07:47:26] Xiti: has joined #ruby
[07:48:15] emilford: has joined #ruby
[07:49:55] jinie: has joined #ruby
[07:52:05] clemens3: has joined #ruby
[07:53:43] schleppel: has joined #ruby
[07:54:18] bambanx: i use vim-gotham is nice sagax
[07:58:52] emilford: has joined #ruby
[08:02:00] sauvin: has joined #ruby
[08:04:08] emilford: has joined #ruby
[08:08:52] lxsameer: has joined #ruby
[08:10:59] keden: has joined #ruby
[08:11:38] KeyJoo: has joined #ruby
[08:12:41] KeyJoo: has joined #ruby
[08:13:39] evdubs_: has joined #ruby
[08:17:51] tdy1: has joined #ruby
[08:19:38] sagax: i will try this
[08:23:31] KeyJoo: has joined #ruby
[08:27:07] suukim: has joined #ruby
[08:29:21] cnsvc: has joined #ruby
[08:41:26] suukim: has joined #ruby
[08:41:46] keden: has joined #ruby
[08:49:14] eightfold: has joined #ruby
[08:49:46] ellcs1: has joined #ruby
[08:52:31] eightfold_: has joined #ruby
[08:57:01] aupadhye: has joined #ruby
[08:58:43] eightfold: has joined #ruby
[08:58:51] qual: has joined #ruby
[09:01:19] jane_booty_doe: has joined #ruby
[09:02:55] Sylario: has joined #ruby
[09:02:55] hightower2: has joined #ruby
[09:07:49] hightower2: has joined #ruby
[09:08:36] themsay: has joined #ruby
[09:19:42] ellcs1: has joined #ruby
[09:20:58] meinside: has joined #ruby
[09:21:19] evdubs_: has joined #ruby
[09:22:08] gloscombe: has joined #ruby
[09:30:27] keden: has joined #ruby
[09:36:11] eightfold: has joined #ruby
[09:39:50] eightfold_: has joined #ruby
[09:46:41] KeyJoo: has joined #ruby
[09:57:14] neo: has joined #ruby
[09:57:53] neo: has left #ruby: ()
[09:58:30] bruce_lee: has joined #ruby
[09:59:10] bruce_lee: has joined #ruby
[09:59:11] bruce_lee: has joined #ruby
[10:00:04] claudiuinberlin: has joined #ruby
[10:06:57] sriehl: has joined #ruby
[10:21:51] DTZUZO: has joined #ruby
[10:24:30] KeyJoo: has joined #ruby
[10:25:23] themsay: has joined #ruby
[10:39:25] ferr: has joined #ruby
[10:40:59] eightfold_: has joined #ruby
[10:43:39] qual: has joined #ruby
[10:43:56] mikecmpbll: has joined #ruby
[11:14:57] sinanislekdemir: has joined #ruby
[11:16:43] jane_booty_doe: has joined #ruby
[11:18:16] alem0lars: has joined #ruby
[11:31:12] aqd: has joined #ruby
[11:41:37] beaky: has joined #ruby
[11:41:44] ldnunes: has joined #ruby
[11:43:59] Ai9zO5AP: has joined #ruby
[11:47:39] conta: has joined #ruby
[11:56:10] alem0lars: has joined #ruby
[11:56:17] eightfold: has joined #ruby
[12:01:11] keden: has joined #ruby
[12:08:49] DaRock: has joined #ruby
[12:16:44] keden: has joined #ruby
[12:18:23] mangold_: has joined #ruby
[12:21:39] v01d4lph4: has joined #ruby
[12:27:03] kke: solarized dark for everything
[12:44:49] ray479: has joined #ruby
[12:45:03] ray479: hello im trying regex with Ruby
[12:46:21] ubuntuisloved: has joined #ruby
[12:46:36] ray479: is there a gem to valid email in ruby ?
[12:46:48] ray479: i mean check valid email
[12:46:56] za1b1tsu: has joined #ruby
[12:56:18] keden: has joined #ruby
[13:09:41] eightfold: has joined #ruby
[13:10:21] ytti: regexp is poor way to validate email, if it needs to be absolutely right
[13:10:29] ytti: you'd need proper parser with lexer and tokenizer
[13:10:45] ytti: if it needs to be just approximately right then it's not really worth a gem
[13:22:26] ubuntuisloved: has joined #ruby
[13:26:48] ljarvis_: has joined #ruby
[13:26:56] TheBrayn: what are even usecases for 100% validating an email address?
[13:27:35] stryek: has joined #ruby
[13:35:28] fluxAeon: has joined #ruby
[13:35:59] Fusl: has joined #ruby
[13:39:04] crankharder: has joined #ruby
[13:39:22] ytti: not losing customer who couldn't sign up because you wouldn't accept their email
[13:39:32] ytti: seems odd question to ask
[13:40:00] ytti: because then question rises, well, how correct must it be?
[13:40:13] ytti: i have trouble signing in with email addres from domain @0b.fi
[13:40:24] ytti: many validators expect domain not to start with number
[13:40:31] ytti: many validators expect domain to be longer than two characters
[13:44:14] helpa-bot: has joined #ruby
[13:46:05] chromis: has joined #ruby
[13:46:17] ljarvis_: has joined #ruby
[13:46:44] helpa: has joined #ruby
[13:48:53] cyberarm_: has joined #ruby
[13:56:25] lucasb: has joined #ruby
[13:58:41] Inline: has joined #ruby
[13:59:34] jcalla: has joined #ruby
[14:07:16] Stan: has joined #ruby
[14:11:31] Swyper: has joined #ruby
[14:14:35] p0s1x: has joined #ruby
[14:15:04] Swyper: has joined #ruby
[14:21:45] Fusl: has joined #ruby
[14:43:18] Rapture: has joined #ruby
[14:46:47] apparition: has joined #ruby
[14:48:02] Stan: has joined #ruby
[14:51:55] stanc: has joined #ruby
[14:52:52] mikecmpb_: has joined #ruby
[14:55:12] polishdub: has joined #ruby
[14:56:20] al2o3-cr: has joined #ruby
[15:04:36] Nicmavr: has joined #ruby
[15:08:18] AJA4350: has joined #ruby
[15:10:39] conta: has joined #ruby
[15:10:44] gnufied: has joined #ruby
[15:12:08] Swyper: has joined #ruby
[15:16:34] conta: has joined #ruby
[15:34:23] zleap: has joined #ruby
[15:34:24] zleap: has joined #ruby
[15:45:08] DTZUZO: has joined #ruby
[15:50:58] v01d4lph4: has joined #ruby
[15:58:27] Tau: has joined #ruby
[16:02:43] AJA4351: has joined #ruby
[16:09:55] conta: has joined #ruby
[16:11:05] robotcars1: has joined #ruby
[16:19:00] dante: has joined #ruby
[16:24:56] [Butch]: has joined #ruby
[16:25:27] robotcars: has joined #ruby
[16:26:07] emilford: has joined #ruby
[16:26:48] duderonomy: has joined #ruby
[16:29:21] conta: has joined #ruby
[16:37:54] marcoecc: has joined #ruby
[16:38:22] VladGh: has joined #ruby
[16:38:40] ubuntuisloved: has joined #ruby
[16:40:17] VladGh: has joined #ruby
[16:43:13] Swyper: has joined #ruby
[16:44:14] Swyper: has joined #ruby
[16:45:15] cthulchu: has joined #ruby
[16:54:34] emilford: has joined #ruby
[16:54:58] mikecmpbll: has joined #ruby
[17:01:03] ljarvis_: has joined #ruby
[17:07:55] emilford: has joined #ruby
[17:10:43] robotcars1: has joined #ruby
[17:12:56] robotcars2: has joined #ruby
[17:13:22] roychri: has joined #ruby
[17:16:13] szulak_: has joined #ruby
[17:17:31] roychri: has left #ruby: ()
[17:18:40] sgen: has joined #ruby
[17:19:16] robotcars: has joined #ruby
[17:20:28] robotcars1: has joined #ruby
[17:20:53] robotcars1: has joined #ruby
[17:24:23] zleap: has joined #ruby
[17:24:23] zleap: has joined #ruby
[17:26:38] jack479: has joined #ruby
[17:26:45] jack479: Hello guys
[17:28:08] eightfold: has joined #ruby
[17:29:02] jack479: How can i match string that can contain [a-z] [0-9] and a '-' ( provided that it is not the first or last character) ?
[17:30:05] jack479: i tried string =~ /[a-zA-Z\-]/ ; doesn't works
[17:30:13] jack479: anyone have an idea ?
[17:42:07] amil: has joined #ruby
[17:42:57] crankharder: has joined #ruby
[17:43:46] v01d4lph4: has joined #ruby
[17:46:07] leftylink: jack479: there are probably two parts to your question but if I assume that we are focusing on how to include a hyphen inside a character class, then https://www.regular-expressions.info/charclass.html is probably helpful
[17:47:02] jack479: leftylink: oh thank you ! :)
[17:48:57] leftylink: one thing to note is that the escaping you did (with a backslash) does indeed cause the hyphen to be included in the character class
[17:51:09] robotcars: has joined #ruby
[17:53:26] leftylink: if instead we focus on a different part of the question (how to express "- can't be the first or last character"), though there might be multiple ways to express this, one way that comes to mind is to say, well, the valid characters for the first/last character are the characters other than hyphen, and the valid chars for those in the middle are including hyphen
[17:55:21] ljarvis: jack479: [a-z0-9][a-z0-9-][a-z0-9] ? :)
[17:56:07] ljarvis: add a + after the second char class
[17:59:26] jcarl43: has joined #ruby
[18:10:02] leftylink: hm. thinking about ranges has got me thinking
[18:10:11] leftylink: if you have a range that is "unusual" what happens...
[18:10:32] leftylink: &>> /[A-z]/ =~ (?A.ord + 28).chr; $~
[18:10:33] rubydoc: # => #<MatchData "]"> (https://carc.in/#/r/6gai)
[18:10:47] ljarvis: A-z isn't really unusual
[18:10:47] leftylink: thought it might have been something like that
[18:10:51] zachk: has joined #ruby
[18:11:07] ljarvis: well, i guess it is unusual, just not really something i'd expect to fail
[18:11:28] leftylink: hopefully anyone who uses it is okay with it matching the 6 chars in between
[18:11:31] ljarvis: i was thinking you meant a-9 or something, which would raise an error (i think)
[18:12:10] leftylink: &>> /[a-9]/
[18:12:10] rubydoc: stderr: -e:2: empty range in char class: /[a-9]/ (https://carc.in/#/r/6gaj)
[18:13:26] leftylink: &>> (0..255).select { |c| /[9-a]/.match?(c.chr) }.minmax
[18:13:26] rubydoc: # => [57, 97] (https://carc.in/#/r/6gak)
[18:14:57] eightfold: has joined #ruby
[18:16:52] snk: has joined #ruby
[18:18:10] v01d4lph4: has joined #ruby
[18:28:36] ravenousmoose: has joined #ruby
[18:34:05] zachk: has joined #ruby
[18:36:10] leftylink: to be fair I didn't check that the range is continuous
[18:44:30] bjpenn: has joined #ruby
[18:44:41] sphenxes: has joined #ruby
[18:51:46] sameerynho: has joined #ruby
[18:53:31] v01d4lph4: has joined #ruby
[18:55:21] [Butch]: has joined #ruby
[18:55:45] DTZUZO: has joined #ruby
[18:56:10] yqt: has joined #ruby
[18:57:01] aqd: has joined #ruby
[18:58:25] mikecmpbll: has joined #ruby
[19:03:03] Renich: has joined #ruby
[19:05:48] jack479: ok, will try on my side
[19:05:53] jack479: get back to you guys
[19:19:39] Swyper: has joined #ruby
[19:25:49] millerti: has joined #ruby
[19:30:44] orbyt_: has joined #ruby
[19:34:38] Swyper: has joined #ruby
[19:36:54] sphenxes: has joined #ruby
[19:39:29] ravenousmoose: has joined #ruby
[19:42:14] orbyt_: has joined #ruby
[19:43:10] Swyper: has joined #ruby
[19:45:17] hightower3: has joined #ruby
[19:47:33] naught-fowl: has joined #ruby
[19:48:00] v01d4lph4: has joined #ruby
[19:48:41] dinfuehr_: has joined #ruby
[19:49:06] zachk: has joined #ruby
[19:49:53] zachk: has joined #ruby
[20:05:39] nwradio: has joined #ruby
[20:06:43] _mak: has joined #ruby
[20:06:46] _mak: hi there
[20:07:35] nwradio: sup my guy
[20:07:49] _mak: is there a way to convert: {"key1"=>"value1"} into {key1: "value1"}?
[20:08:28] nwradio: unfortunately i'm pretty new to ruby so i cannot help you at the moment
[20:08:34] sagax: how to right catch/throw ?
[20:09:17] Swyper: has joined #ruby
[20:10:19] sagax: i am not about begin/rescue
[20:10:30] _mak: sagax: http://rubylearning.com/satishtalim/ruby_exceptions.html
[20:12:07] Dbugger: has joined #ruby
[20:13:25] _mak: what's the name of this `{key1: "value1"}?
[20:13:46] _mak: it is not json right, because on json the key is between quotes
[20:14:18] snk: that's ruby 1.9+ hash syntax
[20:14:56] _mak: but when I convert my {"key1"=>"value1"} into hash I get the same thing
[20:15:48] snk: pre 1.9 hash syntax is still valid
[20:16:18] snk: the latter example there is slightly different, in that the key will be a symbol instead of a string
[20:16:36] _mak: in it possible to convert it?
[20:17:33] _mak: found it!
[20:17:33] naught-fowl: Hash[ somehash.map {|k,v| [k.to_sym, v]} ]
[20:17:40] _mak: with your 'symbol' keyword
[20:17:46] _mak: hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
[20:17:57] _mak: nice thanks!
[20:18:01] snk: rubocop can do it... though i'd be careful in any places where you rely on the key being a string?
[20:19:32] _mak: didn't work :(
[20:19:42] _mak: not all levels of the hash have been converted into symbols
[20:39:42] AJA4350: has joined #ruby
[20:43:22] nowhereman: has joined #ruby
[20:48:43] go|dfish: has joined #ruby
[20:55:51] n13z: has joined #ruby
[20:57:08] Swyper: has joined #ruby
[20:59:06] szulak_: has joined #ruby
[21:01:26] SeepingN: has joined #ruby
[21:13:04] gix: has joined #ruby
[21:19:51] Fernando-Basso: has joined #ruby
[21:24:12] tiogrand_: has joined #ruby
[21:41:25] naught-fowl: has joined #ruby
[21:42:19] FastJack: has joined #ruby
[21:43:03] ua: has joined #ruby
[21:50:03] noobineer: has joined #ruby
[21:53:51] BTRE: has joined #ruby
[22:00:40] mkroman: what's an efficient way to generate a sha256 digest for a file in Ruby?
[22:00:54] havenwood: mkroman: it's in the stdlib under Digest
[22:01:03] mkroman: for files?
[22:01:13] havenwood: for anything
[22:01:53] mkroman: unless the API lets me do it directly from IO it's gonna be slow as balls in Ruby
[22:02:44] dviola: has joined #ruby
[22:04:51] havenwood: &ri Digest::SHA256.file
[22:04:51] rubydoc: parser error at position 0 around `r'
[22:05:14] havenwood: &ri Digest::SHA256::file
[22:05:14] rubydoc: parser error at position 0 around `r'
[22:05:34] havenwood: mkroman: anyhow, you can use Digest::SHA2 with IO
[22:07:06] mkroman: damnit, so I can…
[22:07:20] mkroman: thanks! and sorry for bothering you, kinda should've looked it up myself :p
[22:07:52] redmedic: has joined #ruby
[22:08:51] redmedic: cross posting from the #cinch channel but its pretty inactive. Im using cinch to try and make an irc bot that can use memoserv and Im not seeing anything in the gem to interact with it.
[22:10:03] mkroman: memoserv should just be a reserved user on the network that you talk to, any commands you want to send to it you can do through privmsg's
[22:12:34] sagax: i see this http://phrogz.net/programmingruby/tut_exceptions.html and this https://gist.github.com/JoshTGreenwood/4122195 and this https://jacopretorius.net/2012/01/catch-and-throw-in-ruby.html
[22:12:53] sagax: but i don't understand - right way to use throw/catch
[22:13:05] hightower3: has joined #ruby
[22:13:35] sagax: catch :foo do throw :foo end - it's strange
[22:16:17] mkroman: havenwood: https://gist.github.com/mkroman/f9b1673721bcdeb8e6daf25129d87190 in case you were curious
[22:16:59] mkroman: (and yes, I know it depends heavily on the system cache and the fact that it's on a tmpfs, but there's still a significant difference)
[22:17:41] mkroman: and the overhead might be entirely in the process spawning
[22:17:42] AJA4350: has joined #ruby
[22:19:27] mkroman: sagax: are you asking as a beginner or are you looking to optimize code?
[22:20:56] sagax: i want understand catch/throw
[22:21:42] baweaver: sagax: Use begin / rescue
[22:21:57] mkroman: honestly, I've never seen catch/throw used in real life
[22:22:04] sagax: i need catch/throw
[22:22:34] leftylink: I forgot catch / throw exists
[22:24:21] mkroman: sagax: from what I gather the difference is that catch/throw won't have *any* stack information, backtrace log, error type or message
[22:24:53] ytti: afaik it is 'goto'
[22:25:08] ytti: i have no idea of what the application might be
[22:25:42] ytti: i suspect more idiomatic solution exists to most or all problems
[22:25:50] mkroman: whereas rescue/raise will create a whole object, reverse the stack and store the backtrace in it just to give you more information
[22:27:04] mkroman: if you need exceptions to be performant, you're doing something wrong.
[22:27:19] sagax: catch/throw can return result
[22:27:26] leftylink: that is interesting.
[22:27:28] sagax: and catch/throw can stop block
[22:27:35] sagax: just stop
[22:27:38] sagax: without exception
[22:27:44] sagax: stop and return something
[22:31:39] leftylink: &>> catch(:hello) { 1.step { |n| throw :hello, n if Math.log(Math.log(n)) >= Math::E } }
[22:31:41] rubydoc: # => 3814280 (https://carc.in/#/r/6gci)
[22:31:43] leftylink: so, I could do that, if I felt like
[22:31:50] leftylink: but I wuld rather use 1.step.find in this instance
[22:31:58] baweaver: sagax: Use begin / rescue, you'll have a lot easier time.
[22:32:00] leftylink: or I would use a function and return frmo it maybe?
[22:32:08] baweaver: What code do you _need_ it for?
[22:32:27] baweaver: begin / rescue can also return a result.
[22:33:10] sagax: begin/rescue it's about exceptions,
[22:33:12] baweaver: Very often when one thinks they _need_ a language feature that's not entirely accurate. It depends heavily on context, and sometimes we're bent on shoehorning our problem to match.
[22:33:16] sagax: but i don't need it
[22:33:43] baweaver: What problem are you trying to solve?
[22:33:44] baweaver: because it sounds a lot like `break` or `next`
[22:34:07] sagax: i need just stop function and return something
[22:34:11] baweaver: You're fixating on try/catch, not your actual problem.
[22:34:15] sagax: all this can do catch/throw
[22:34:18] baweaver: Do you have a code example?
[22:34:38] baweaver: You can use `return` for that as well.
[22:34:40] leftylink: if you want to stop a function and return something, then it sounds like you want `return`, not try/catch
[22:34:45] leftylink: ... beaten to the punch
[22:34:50] sagax: no, return it's ugle
[22:34:59] sagax: it's like as switch/case
[22:35:07] sagax: or if/else/if/else/if/else
[22:35:22] baweaver: Can you show us some example code?: https://dpaste.de
[22:35:44] baweaver: What if we said that try/catch is ugly?
[22:35:53] sagax: ok, i show,
[22:35:55] baweaver: If you're bent on using it, use it.
[22:44:49] mochiyoda: has joined #ruby
[22:47:48] SuperL4g: has joined #ruby
[22:50:42] AJA4351: has joined #ruby
[22:54:19] mkroman: sagax: if your code is proliferated with if else if else, you might want to use if guards
[23:01:41] nowhereman: has joined #ruby
[23:06:46] sagax: http://susepaste.org/view//43558323
[23:07:47] sagax: it's simple examples
[23:08:08] baweaver: Yeah, just use `return`.
[23:08:53] sagax: if i use return i need if/else/if/else/if/else
[23:09:00] sagax: throw i can call in any place
[23:09:04] baweaver: You're not gaining any clarity there.
[23:09:43] baweaver: If anything you're trying to ad-hoc on pattern matching
[23:09:54] sagax: return "something" if some - it's not what i need
[23:10:01] baweaver: It's an approximation of an Either type.
[23:10:32] baweaver: You're using throw/catch as a psuedo-either type to pass additional context with returns
[23:10:49] baweaver: It's more commonly known as Railway Oriented Programming: https://fsharpforfunandprofit.com/rop/
[23:10:55] sagax: i use throw to stop function
[23:11:42] baweaver: I'm not really sure what you want here.
[23:11:44] baweaver: You're fixated on one solution, so just use it.
[23:11:53] baweaver: Just be warned it's not very common and will likely confuse other programmers.
[23:16:49] Swyper: has joined #ruby
[23:18:43] phaul: ah. 256 is not allowed in class namesin my parser. sorry havenwood I fix it
[23:19:19] phaul: &ri Digest::SHA
[23:19:19] rubydoc: Found no entry that matches class Digest::SHA
[23:19:22] phaul: &ri Digest::SHA256
[23:19:23] rubydoc: parser error at position 0 around `r'
[23:21:00] phaul: ruby syntax rules are super complex :)
[23:25:25] Autolycus: has joined #ruby
[23:28:57] gigetoo: has joined #ruby
[23:29:54] Swyper: has joined #ruby
[23:33:12] rafadc: has joined #ruby
[23:35:36] tdy1: has joined #ruby
[23:54:49] cnsvc: has joined #ruby
[23:59:05] AJA4351: has joined #ruby