« Back to channel list

#ruby - 06 May 2018

« Back 1 day Forward 1 day »
[00:04:07] eckhardt: has joined #ruby
[00:06:41] apeiros: has joined #ruby
[00:07:27] DTZUZO: has joined #ruby
[00:12:52] Yzguy: has joined #ruby
[00:14:07] Guest3700: has joined #ruby
[00:22:18] luminousnine: has left #ruby: ("Kicked by @appservice-irc:matrix.org : removing from IRC because user idle on matrix for 30+ days")
[00:23:25] ur5us: has joined #ruby
[00:25:22] TinkerT: has joined #ruby
[00:28:20] orbyt_: has joined #ruby
[00:28:28] gheegh: has joined #ruby
[00:28:49] x77686d: has joined #ruby
[00:32:59] luna_x[m]: has left #ruby: ("Kicked by @appservice-irc:matrix.org : removing from IRC because user idle on matrix for 30+ days")
[00:38:19] CrazyEddy: has joined #ruby
[00:39:31] apeiros: has joined #ruby
[00:42:40] gheegh: has joined #ruby
[00:51:30] chocoelho: has joined #ruby
[00:54:40] x77686d: has joined #ruby
[00:55:02] gheegh: has joined #ruby
[00:57:16] n0m4d1c: has joined #ruby
[01:02:58] conta: has joined #ruby
[01:07:28] chocoelho: has joined #ruby
[01:08:11] gheegh: has joined #ruby
[01:12:56] jottr: has joined #ruby
[01:16:32] x77686d: has joined #ruby
[01:19:23] gheegh: has joined #ruby
[01:24:50] hays: is it fair to say that if i want a singleton, I should probably just have a class with class methods?
[01:28:02] arekushi: has joined #ruby
[01:29:34] Zarthus: hays: i think ruby has a thing for this already
[01:30:31] gheegh: has joined #ruby
[01:30:57] Zarthus: &ri singleton
[01:34:56] Puffball: has joined #ruby
[01:39:29] karapetyan: has joined #ruby
[01:42:07] mostly-harmless: has joined #ruby
[01:42:11] gheegh: has joined #ruby
[01:44:45] cschneid_: has joined #ruby
[01:45:38] dinfuehr: has joined #ruby
[01:47:24] AJA4351: has joined #ruby
[01:52:01] Tempesta: has joined #ruby
[01:52:12] lupine: has joined #ruby
[01:52:43] hays: hmm so i guess there are two ways..
[01:53:07] hays: im just trying to wrap my head around classes being objects also, and how that might be actually used
[01:54:02] bmurt: has joined #ruby
[01:54:59] chocoelho: has joined #ruby
[01:56:38] garyserj: baweaver: here is a case where I prefer goto, https://repl.it/repls/DarkorchidWaryHashmap
[01:56:59] hays: i guess one thing nice about using the Singleton module is that you can make something a singleton or not pretty easily, whereas if you make things classes and class methods, there's going to be more refactoring
[01:57:14] baweaver: garyserj: you don't need it
[01:57:24] baweaver: that's what exit and abort are for
[01:58:10] garyserj: I don't want to exit the whole program. e.g. say i'm running sinatra web server I don't want the server to shut down
[01:58:25] baweaver: This is what modules, classes, and methods are for.
[01:58:27] gizmore: has joined #ruby
[01:58:40] gheegh: has joined #ruby
[01:58:41] baweaver: goto was an old variant of flow control from before such things really existed
[01:58:56] baweaver: so to superimpose it into a language which has these concepts is not a great idea
[01:59:18] garyserj: well as I showed, I managed without a goto, by using an extra nesting of if statement
[01:59:33] baweaver: What's your actual code?
[01:59:36] garyserj: Gotos can be used to implement many things.. they can be used as an alternative to methods.
[01:59:50] garyserj: I only have the simplified example. (which is actually clearer)
[02:00:03] garyserj: but I didn't use a goto as an alternative to a method
[02:00:15] garyserj: The ban on Gotos is actually more controversial than you think
[02:00:18] baweaver: 's not, it's just bad design
[02:00:26] garyserj: There is a paper called "Goto considered harmful, considered harmful"
[02:00:54] garyserj: which states quite rightly that no more should an entire word be considered a bad thing.. like banning a word from a language.
[02:00:56] garyserj: it can be used or abused.
[02:01:19] baweaver: and you're abusing it in a language which has features which invalidate its use
[02:01:21] hays: here is the thing--most people work with other people, so it 99% of the world doesn't want to use goto, its probably a bad idea unless there is a large benefit
[02:01:32] kapil___: has joined #ruby
[02:01:35] gheegh: has joined #ruby
[02:01:38] garyserj: well I didn't use it, I used an extra nesting of if, though it is a bit uglier.
[02:02:11] hays: even Dijkstra's original paper talked about ways to use goto that were valid, but argued that developers tended to use it in ways that led to problems
[02:02:23] hays: at least that's what I remember when I read the paper--its been a while
[02:02:42] garyserj: yeah and somebody that knows about the ugly uses of goto can use it in an ok manner.
[02:02:45] garyserj: not an ugly usage.
[02:02:49] baweaver: garyserj: What's the actual code?
[02:03:00] garyserj: I only have the simplified version at the moment, but it is totally clear
[02:03:03] garyserj: what's the problem with it?
[02:03:06] baweaver: because I guarantee you there's a better more testable way to do it
[02:03:16] garyserj: i'm shown you a very simple example why can't you use that?
[02:03:19] baweaver: My problem is you're coming across as trolling, quite frankly.
[02:03:24] gheegh: has joined #ruby
[02:03:36] garyserj: ok well let's not have the discussion about goto then.
[02:04:16] baweaver: It's not even really a discussion. You provided a sample which doesn't actually show your usecase
[02:04:17] baweaver: and now insist it's valid applied to a larger application.
[02:04:31] hays: i prefer the below, although if A()==true was cheap, I'd consider just flattening it a bit and just having 3 cases
[02:04:31] cschneid_: has joined #ruby
[02:04:51] baweaver: we assert that there are language features that make the usage of such completely unnecessary
[02:05:19] garyserj: baweaver: okay.
[02:05:28] chocoelho: has joined #ruby
[02:05:36] baweaver: You're likely using it for flow control in a single action of a Sinatra controller of sorts.
[02:05:41] garyserj: hays: yes I thought of that too, that's a good idea
[02:06:16] baweaver: Most conditional logic can be refined further into classes and modules for easier testing and reuse
[02:06:28] baweaver: and more than likely the reason you would have to do heavy conditional checks is that you don't really have a RESTfully oriented routing setup
[02:07:10] hays: baweaver: i remember seeeing examples of that in Strousoups old C++ book and I didn't really get it
[02:07:29] gheegh: has joined #ruby
[02:07:35] baweaver: This cascades into multiple levels of design concern in which the thing that doesn't make sense isn't the dislike of goto, but the dislike of patterns that have long since made its usage a crutch
[02:07:43] hays: how might one eliminate conditional logic in the simple case we're talking about here
[02:08:16] baweaver: It depends, which is why I keep asking for what the actual code is
[02:08:36] baweaver: You cannot derive the concern of the application from names like A, B, yyy, and zzz
[02:08:54] baweaver: So using them to make an assertion about the validity of goto is an architectural sham.
[02:09:03] garyserj: hays: do you think it matters what A,B,yyy,zzz are?
[02:09:21] garyserj: it's not to do with testing something that would or could be in the URL anyway.
[02:09:33] garyserj: so it's not like more routes would make a difference.
[02:10:07] hays: garyserj: it might. but I actually think the structured version is cleaner than using goto
[02:10:16] baweaver: Are they routed objects based on params, are they queries, url segments, child objects? It could be a lot of things.
[02:10:27] garyserj: hays: with three ifs, I think so. With the extra nesting I don't think so.. though we disagree there with the latter.
[02:10:49] baweaver: What is the exact task you're trying to accomplish?
[02:10:59] baweaver: Because this veers very heavily into the XY problem
[02:11:07] ruby[bot]: it seems like you are asking for a specific solution to a problem, instead of asking about your problem. This often leads to bad solutions and increases frustration for you and those trying to help you. More: http://meta.stackexchange.com/a/66378
[02:11:38] baweaver: You have a solution you want, and are fixated on it to the detriment of all possible better solutions.
[02:12:23] garyserj: baweaver: you accused me of trolling as if i'm trying to provoke this conversation with you about goto further but i'm not.
[02:13:08] hays: I think "The Practice of Programming" would suggest flattening the logic
[02:13:23] baweaver: It's because it's so unnecessary in the language that I'm trying to warn you of it
[02:13:29] hays: Kernighan is pretty old school though
[02:14:26] hays: baweaver: I've definitely struggled with complex/nested logic when doing state machine kind of stuff for various logic controllers. sometimes its hard to avoid things looking a bit spaghetti like
[02:14:52] baweaver: State machines are a hard problem to solve for.
[02:15:07] garyserj: hays: spaghetti like and nested ifs are very different things.. nested ifs, while they can be ugly, are technically not spaghetti code.
[02:15:23] garyserj: spaghetti code would be Gotos jumping all over the place.
[02:15:29] baweaver: This is a good read on the subject - http://raganwald.com/2018/02/23/forde.html
[02:15:39] garyserj: no gotos and it may still be ugly though technically not spaghetti code, just ugly code ;-)
[02:16:16] baweaver: I'd argue that more than a few nested ifs are also bad code.
[02:16:22] yxhuvud: has joined #ruby
[02:16:25] baweaver: It means your object or method knows too much and should likely be broken down more.
[02:16:51] baweaver: That primarily gets into Metz's rule and Single Responsibility Principle
[02:17:04] baweaver: Though the Metz rule can be a bit extreme.
[02:17:47] bzb: has joined #ruby
[02:18:10] hays: the number of states often ends up going up by 2^n
[02:18:26] hays: logic ends up being the only way to combat that
[02:18:56] mroutis: has joined #ruby
[02:19:05] garyserj: you could flatten nested ifs into multiple ones with longer conditionals.. How are you solving that with more methods?
[02:19:09] hays: the machine is suppose to do x,y,z except there's this global override. and this other thing. and oh yeah if there's a fire than this changes.. etc.
[02:19:32] garyserj: hays: yeah I don't think there is any getting around logic like that.
[02:19:34] baweaver: It depends so much on what you're expressing
[02:19:42] garyserj: methods have nothing to do with it
[02:20:16] baweaver: and that's the dig, you cannot abstractly capture that level of nuance with fake names and short examples.
[02:21:17] baweaver: The biggest problem behind all of this is it's absolutely impossible to test.
[02:21:47] baweaver: 100 line methods, imperative scripts, all of it: how do you test each component piece that makes an application? You can't without a lot of mess.
[02:22:02] garyserj: well, iirc the example I had was.. get '/' do then check params[:g].has_key?(:tempfile) (that was condition A). if it does then test if the file ends in .htm or .html. (That was condition B).
[02:22:13] gheegh: has joined #ruby
[02:22:17] baweaver: and once you get into larger applications that are customer facing or mission critical?
[02:22:37] garyserj: baweaver: nobody is suggesting not using methods and nobody is suggeseting having 100 lines of code not broken into a different method.
[02:22:51] hays: and yet so much safety related code is nested logic and state machines
[02:23:05] conta: has joined #ruby
[02:23:07] garyserj: methods have nothing to do with this, it's a complete red herring
[02:23:20] garyserj: hays: I agree
[02:23:43] rkazak: has joined #ruby
[02:23:59] gheegh: has joined #ruby
[02:24:00] hays: and if you told customers you were writing their product in ruby they'd probably fire you and hire someone to put it into a terrible thing like this https://selinc.com/products/3555/
[02:24:09] ur5us: has joined #ruby
[02:24:25] baweaver: I've worked on the same code. That doesn't make it good or even acceptable.
[02:25:38] baweaver: Especially around SCADA and controllers in general, then even further back into RPG and COBOL era
[02:26:15] hays: oh yeah its all a nightmare and a big false sense of security
[02:26:17] baweaver: If you wanted to change something you were basically screwed.
[02:26:58] hays: yep, some coke addict wrote the code 20 years ago, no one has a copy, and if you go and extract it you are not ging to like what you see
[02:27:37] baweaver: Thing is, we've moved on as an industry from a lot of it to a lot more testable interfaces.
[02:28:42] mroutis: has joined #ruby
[02:29:02] baweaver: Now logic around handling how to write something given suffixes, that should likely be a handler of some sort meant to handle how a route responds to something
[02:29:15] baweaver: param wise, unless it's an index with a search action that's a hint you need more routes.
[02:29:26] baweaver: primarily oriented towards resources you need to express
[02:29:41] jready: has joined #ruby
[02:29:46] baweaver: We had one recently where someone loaded everything into '/' using params for dispatch, that's not ok.
[02:30:17] baweaver: Turns out a lot of the actions had to do with solid concepts like hosts, databases, and other definitive objects you're performing actions against
[02:30:35] hays: well sure you're talking about REST
[02:31:49] garyserj: baweaver: that doesn't make sense. in my case I have a form, they select a file and click submit. It makes a request, to one route.
[02:31:51] gheegh: has joined #ruby
[02:32:05] garyserj: the problem isn't solved by multiple routes.
[02:32:16] baweaver: A lot of it is that things just do too much and become impossible to test or reason about after a while
[02:32:17] baweaver: garyserj: OH! So there is context
[02:32:32] baweaver: and what do you know, context changes concerns
[02:32:36] garyserj: well you keep being very presumptuous about the code
[02:32:47] garyserj: and each time, wrongly.
[02:33:19] garyserj: And now that you know more about it, can you tell me how my simplified example that I gave you, changes whatever solution you haven't come up with?
[02:33:35] gheegh: has joined #ruby
[02:34:09] garyserj: you were incorrect when you said you could solve it with more methods, and incorrect when you said you could solve it with more routes. So now you know more, how would you solve it?
[02:34:36] baweaver: garyserj: I accuse you of trolling because you come with an incredibly generic solution to make a point, and once I start trying to go around potentially related concerns you start going even further in on it.
[02:34:37] garyserj: I think what hays said, of flattening the ifs, is perfectly good. And totally based on my simplified example.
[02:35:05] garyserj: adding all that detail you wanted hasn't helped anybody.
[02:35:24] Haradani: has joined #ruby
[02:35:53] garyserj: and you still accuse me of trolling? I only continued the discussion with you because you kept requesting that I continue it.
[02:35:58] Ryzokuken: has joined #ruby
[02:37:03] Haradani: has joined #ruby
[02:38:36] hays: another way to avoid the goto is to have the block of code in function and use early returns. that can get ugly too though
[02:38:55] hays: it has a similar problem as goto
[02:40:04] garyserj: i think that is the ugliest!
[02:40:35] gheegh: has joined #ruby
[02:41:17] roamingdog: has joined #ruby
[02:41:46] hays: it works sometimes but yes i agree
[02:42:19] garyserj: way way back I learnt the harm of over-modularisation
[02:43:57] gheegh: has joined #ruby
[02:46:59] mroutis: what's going on?
[02:47:00] Haradani: has joined #ruby
[02:47:27] gheegh: has joined #ruby
[02:47:54] hays: garyserj wants goto :)
[02:49:37] za1b1tsu: has joined #ruby
[02:50:21] Haradani: has joined #ruby
[02:51:05] gheegh: has joined #ruby
[02:51:43] mroutis: and what about the routes and REST part, hays? I'm a little bit lost, hehe
[02:54:20] hays: garyserj: dijkstra seems to have blown frank rubin's response out of the water https://www.cs.utexas.edu/users/EWD/transcriptions/EWD10xx/EWD1009.html
[02:55:32] hays: i think baweaver was trying to say that well designed software interfaces and modern programming language features completely eliminate the temptation of using goto, but i might be micharacterizing it
[02:56:16] baweaver: Pretty much, then laying out normal concerns people tend to reach for it in and how to get around it.
[02:56:32] mroutis: makes sense
[02:56:35] baweaver: ...which apparently was taken as an answer
[03:00:10] cadillac_: has joined #ruby
[03:02:15] gheegh: has joined #ruby
[03:11:27] gheegh: has joined #ruby
[03:13:46] jottr: has joined #ruby
[03:15:16] gheegh: has joined #ruby
[03:17:08] conta: has joined #ruby
[03:18:44] yxhuvud: has joined #ruby
[03:19:25] gheegh: has joined #ruby
[03:22:17] gheegh: has joined #ruby
[03:25:02] gheegh: has joined #ruby
[03:27:15] karapetyan: has joined #ruby
[03:28:11] yxhuvud: has joined #ruby
[03:29:19] gheegh: has joined #ruby
[03:33:21] yxhuvud: has joined #ruby
[03:34:10] gheegh: has joined #ruby
[03:39:13] gheegh: has joined #ruby
[03:40:15] hays: reading the Dijkstra/Rubin correspondance is kinda funny
[03:44:59] jsrn: has joined #ruby
[03:49:49] hays: i should write a paper: for loops considered harmful :)
[03:51:02] arescorpio: has joined #ruby
[03:51:27] gheegh: has joined #ruby
[03:53:41] garyserj: somebody might make a response e.g. there is a paper called "goto statements considered harmful, considered harmful"
[03:55:28] gheegh: has joined #ruby
[04:07:15] conta: has joined #ruby
[04:09:38] x77686d: has joined #ruby
[04:19:49] RyanMcCoskrie: has joined #ruby
[04:21:41] hays: seriously, dijkstra skewers that guy
[04:24:18] hays: his answer avoids goto and does not waste a single bit of memory or cpu cycle
[04:24:32] hays: and is incredibly clear
[04:24:59] hays: not exactly in the style of web code written in 2018 but hey
[04:26:02] yxhuvud: has joined #ruby
[04:26:18] hays: i might better say code written for distributed architectures
[04:41:11] conta: has joined #ruby
[04:41:17] face: has joined #ruby
[04:41:19] pwnd_nsfw: has joined #ruby
[04:44:04] konsolebox: has joined #ruby
[04:45:42] matled: has joined #ruby
[04:46:22] roamingdog: has joined #ruby
[04:46:37] herbmillerjr: has joined #ruby
[04:47:32] klaas: has joined #ruby
[04:48:12] Prira: has joined #ruby
[04:48:22] mlehrer: has joined #ruby
[04:48:27] nowhere_man: has joined #ruby
[04:49:26] _zach: has joined #ruby
[04:52:44] psmolen: has joined #ruby
[04:54:03] segy: has joined #ruby
[04:54:09] armyriad: has joined #ruby
[05:10:43] modin: has joined #ruby
[05:11:50] nowhere_man: has joined #ruby
[05:14:37] jottr: has joined #ruby
[05:16:48] alfiemax: has joined #ruby
[05:25:34] nadir: has joined #ruby
[05:26:06] nima_m_: has joined #ruby
[05:28:10] apparition: has joined #ruby
[05:29:46] webhat: has joined #ruby
[05:46:16] pabs: has joined #ruby
[06:05:01] conta: has joined #ruby
[06:25:39] konsolebox: hays: he advocates the use of an extra bool variable (which by concept implies an instruction for assignment, and another for comparison). how does that avoid extra memory or cpu cycle vs. a single goto to a common set of instructions? note that i'm not giving my general opinion of which practice is better yet. but the idea of this guy that everyone hypes about seems to be common sense.
[06:27:52] ldepandis: has joined #ruby
[06:29:47] yaiyaichu: has joined #ruby
[06:38:40] conta: has joined #ruby
[06:53:47] jsrn: has joined #ruby
[06:59:08] apparition: has joined #ruby
[07:03:23] karapetyan: has joined #ruby
[07:07:06] reber: has joined #ruby
[07:07:38] yaiyaichu: has joined #ruby
[07:13:35] coderphive: has joined #ruby
[07:13:59] yaiyaichu: has joined #ruby
[07:15:28] jottr: has joined #ruby
[07:17:12] biberu: has joined #ruby
[07:30:56] cadillac_: has joined #ruby
[07:33:29] eckhardt: has joined #ruby
[07:42:00] luna_x[m]: has joined #ruby
[07:42:04] za1b1tsu: has joined #ruby
[07:45:29] dionysus69: has joined #ruby
[07:46:46] Sembei: has joined #ruby
[07:52:10] apeiros: has joined #ruby
[07:53:02] jamesaxl: has joined #ruby
[07:54:48] marr: has joined #ruby
[07:58:25] clemens3: has joined #ruby
[08:00:39] TinkerT: has joined #ruby
[08:00:45] sameerynho: has joined #ruby
[08:03:45] RougeR: has joined #ruby
[08:03:46] RougeR: has joined #ruby
[08:04:01] schleppel: has joined #ruby
[08:05:27] kent\n: has joined #ruby
[08:18:30] conta: has joined #ruby
[08:26:17] venmx: has joined #ruby
[08:33:44] DTZUZO: has joined #ruby
[08:42:23] alex``: has joined #ruby
[08:45:48] jenrzzz: has joined #ruby
[08:52:03] leitz: has joined #ruby
[08:53:04] leitz: has left #ruby: ()
[09:02:18] karapetyan: has joined #ruby
[09:05:20] dionysus69: has joined #ruby
[09:10:02] blackmesa: has joined #ruby
[09:15:38] tomphp: has joined #ruby
[09:16:23] jottr: has joined #ruby
[09:16:29] za1b1tsu: has joined #ruby
[09:24:30] rabajaj: has joined #ruby
[09:25:05] Mike11: has joined #ruby
[09:26:20] conta: has joined #ruby
[09:31:53] anisha: has joined #ruby
[09:37:47] faces: has joined #ruby
[09:38:38] anisha_: has joined #ruby
[09:38:59] conta: has joined #ruby
[09:39:04] CBebop: has joined #ruby
[09:40:15] klaas: has joined #ruby
[09:40:17] yosafbridge: has joined #ruby
[09:41:48] armyriad: has joined #ruby
[09:43:32] brodul: has joined #ruby
[09:59:23] guille-moe: has joined #ruby
[10:01:20] s2013: has joined #ruby
[10:02:35] jamesaxl: has joined #ruby
[10:05:06] jsrn: has joined #ruby
[10:18:26] t0adst00l: has joined #ruby
[10:19:46] govg: has joined #ruby
[10:24:12] jamesaxl: has joined #ruby
[10:26:03] soniya29: has joined #ruby
[10:26:08] soniya29_: has joined #ruby
[10:28:07] podman: has joined #ruby
[10:32:15] rabajaj: has joined #ruby
[10:32:33] ellcs: has joined #ruby
[10:34:54] jamesaxl: has joined #ruby
[10:35:56] cjs226: has joined #ruby
[10:38:02] jamesaxl: has joined #ruby
[10:40:12] kapil___: has joined #ruby
[10:46:55] jxf: has joined #ruby
[10:48:20] jamesaxl: has joined #ruby
[10:50:37] conta1: has joined #ruby
[10:51:10] s2013: has joined #ruby
[10:56:43] jottr: has joined #ruby
[10:57:32] hays: konsolebox: point taken, there is probably a way to optimize out the bool, although I think that is unrelated to the use of goto but rather from interring the bool from the loop variable value
[10:57:34] marr: has joined #ruby
[10:57:51] nickjj: has joined #ruby
[10:58:02] Tony-St4rk: has joined #ruby
[10:58:07] sanjeevkumar: has joined #ruby
[10:58:47] hays: as for common sense, goto was in pretty widespread use at the time
[11:04:08] InfinityFye: has joined #ruby
[11:05:20] InfinityFye: has left #ruby: ()
[11:07:23] kireevco: has joined #ruby
[11:13:41] dr3wo: has joined #ruby
[11:15:14] boxrick: has joined #ruby
[11:16:01] AJA4350: has joined #ruby
[11:16:28] jabreity: has joined #ruby
[11:21:22] andersh: has joined #ruby
[11:25:44] solidsnack: has joined #ruby
[11:26:10] cttttt: has joined #ruby
[11:28:30] rabajaj: has joined #ruby
[11:28:31] pwillard: has joined #ruby
[11:34:08] peteretep: has joined #ruby
[11:40:42] Mike11: hello all, I have a frozen String str and I want to get a new copy of it after replacing a range of characters within it
[11:40:48] Mike11: currently I am doing something like this:
[11:41:15] Mike11: new_str = String.new str
[11:41:15] Mike11: new_str[range] = replacement
[11:41:15] Mike11: return new_str
[11:41:42] Mike11: but I feel like I am overcomplicating it? is there a more brief way?
[11:44:44] shwouchk: has joined #ruby
[11:46:14] Mike11: so, my question is: is there a method that acts like String#[] but returns a new string instead of mutating the current instance?
[11:47:27] jamesaxl: has joined #ruby
[11:47:38] conta1: has joined #ruby
[11:50:20] andywojo: has joined #ruby
[11:58:16] s2013: has joined #ruby
[12:01:37] MoskitoHero: has joined #ruby
[12:04:04] konsolebox: hays: it would be interesting to get his idea about jumping out of multiple loops. common reply would be encapsulate code inside functions. but that doesn't always work right, and it doesn't always make things simpler. thankfully Ruby has throw and catch, but that's no longer about programming in general, and is about language features which was one he is suggesting not to focus to.
[12:06:30] GodFather: has joined #ruby
[12:12:32] rann: has joined #ruby
[12:14:28] konsolebox: > p = "abc"[1]; puts p.object_id; puts p.dup.object_id
[12:14:36] konsolebox: >> p = "abc"[1]; puts p.object_id; puts p.dup.object_id
[12:14:37] ruby[bot]: konsolebox: # => 546631040 ...check link for more (https://eval.in/999930)
[12:16:44] conta: has joined #ruby
[12:16:49] Mike11: konsolebox: ok, they are different objects, so what?
[12:17:57] konsolebox: Mike11: i thought you wanted to return a new string? `dup` guarantees that.
[12:18:58] Mike11: konsolebox: ah, this would replace my first line only
[12:19:47] konsolebox: Mike11: ok, can you clarify what you want to do?
[12:19:55] hahahahah: has joined #ruby
[12:20:27] hahahahah: hei guys... i never programmed ruby on ma life.. and I need something like this: https://stackoverflow.com/questions/5424354/regex-to-remove-non-letters#5424382 for logstash to convert a url to a action...
[12:20:47] Mike11: konsolebox: seems like there is no one liner for my function. kind of strange that all String functions have mutating and pure versions, while String#[] is an exception
[12:20:47] hahahahah: has joined #ruby
[12:21:13] hahahahah: example: /directory/sub/action.php?var=1&var3=dsgadsa should result in: /directory/sub/action.php how can I test my code? is there a ruby console like python?
[12:21:27] konsolebox: Mike11: String#[] returns a new string as I observe
[12:21:27] DTZUZO: has joined #ruby
[12:21:48] Mike11: konsolebox: sorry, I mean String#[]=
[12:22:21] Mike11: I just want to return a new String that contains the same content of a frozen string after replacing a range
[12:22:22] lupine: hahahahah: /\A([^\?].*)/
[12:22:29] lupine: you can use irb to get an interactive shell
[12:22:50] Mike11: something like this:
[12:22:51] Mike11: new_str = str.dup
[12:22:51] Mike11: new_str[range] = some_other_str
[12:22:51] Mike11: return new_str
[12:22:51] armyriad: has joined #ruby
[12:22:54] hahahahah: lupine: awesomenesss thanks :)))
[12:23:08] konsolebox: Mike11: I see. Then why not string.dup[range]= some_other_string?
[12:23:12] lupine: (note that I'm not familiar with logstash at all)
[12:23:29] Mike11: konsolebox: the whole statement evaluates to some_other_string
[12:24:15] Mike11: konsolebox: seems like the most brief way, no problem, thank you for your help :)
[12:24:56] hahahahah: '/directory/sub/action.php?var=1&var3=dsgadsa '.gsub(/\A([^\?].*)/, '') => "" (i guess is not gsub... :o )
[12:26:12] konsolebox: >> "xyz".dup.tap{ |s| s[1] = "abc"; s } # Mike11
[12:26:15] ruby[bot]: konsolebox: # => "xabcz" (https://eval.in/999932)
[12:26:42] hahahahah: '/directory/sub/action.php?var=1&var3=dsgadsa'.split('?', 0)[0] => "/directory/sub/action.php" works \o/
[12:26:58] Mike11: konsolebox: reading about #tap... thanks
[12:27:38] konsolebox: '; s' seems not necessary
[12:29:19] karapetyan: has joined #ruby
[12:29:58] chocoelho: has joined #ruby
[12:30:51] craysiii: has joined #ruby
[12:31:31] hahahahah: which is the character to split sentences in ruby? :o
[12:32:57] konsolebox: # "abc\nxyz".split("\n") # hahahahah
[12:33:03] konsolebox: >> "abc\nxyz".split("\n") # hahahahah
[12:33:04] ruby[bot]: konsolebox: # => ["abc", "xyz"] (https://eval.in/999936)
[12:33:26] konsolebox: but it fails with CRLF
[12:33:51] konsolebox: >> "abc\r\nabc".split(/\r?\n/) # works with both
[12:33:52] ruby[bot]: konsolebox: # => ["abc", "abc"] (https://eval.in/999937)
[12:35:21] hahahahah: no sorry.. i meant: statement;statement2
[12:39:38] mlehrer: has joined #ruby
[12:43:01] konsolebox: hahahahah: there's no easy way to do that unfortunately. you have to have a solution that can parse php code. `split(';')` would also split semicolons that are no longer part of the syntax scope.
[12:45:27] hahahahah: |: u are complicating the problem.. is way more simple
[12:45:29] anisha_: has joined #ruby
[12:45:40] hahahahah: i just needed to put too statements of ruby in one single line.. lol
[12:46:59] sina: has joined #ruby
[12:47:08] dr3wo: has joined #ruby
[12:49:35] konsolebox: hahahahah: try to give an example then, and elaborate what your target goal is
[12:49:41] KnownSyntax: has joined #ruby
[12:52:25] hahahahah: Ruby exception occurred: undefined method `split' for nil:NilClass how can i avoid this? :o or check if the string exists?
[12:53:47] kspencer: has joined #ruby
[12:55:05] dr3wo: has joined #ruby
[12:57:15] hahahahah: konsolebox: nevermind.. :| THIS is the solution -> code => 'event.set("response_time_ms", event.get("response_time").to_f * 0.001); event.set("action", event.get("request").to_s.split("?", 0)[0])'
[12:58:10] konsolebox: hahahahah: looks like you have to check if get("request") returns a string or not
[13:00:49] MyMind: has joined #ruby
[13:01:09] hahahahah: konsolebox: stupid bot. |:
[13:03:29] rippa: has joined #ruby
[13:04:42] konsolebox: hahahahah: me stupid? sure, if that makes you feel smarter.
[13:05:43] rabajaj: has joined #ruby
[13:38:19] psychicist__: has joined #ruby
[13:41:27] cschneid_: has joined #ruby
[13:43:10] DLSteve: has joined #ruby
[13:50:53] cschneid_: has joined #ruby
[14:00:28] epochwolf: has joined #ruby
[14:04:16] gr33n7007h: has joined #ruby
[14:05:58] hph^: has joined #ruby
[14:08:59] tvN: has joined #ruby
[14:16:16] garyserj: hays: that link just has dijkstra making his case that frank rubin is a bad programmer. IF you look at the example in the second answer here https://stackoverflow.com/questions/3517726/what-is-wrong-with-using-goto It is *Exactly* the usage I used.. which is described as a good use of Goto.
[14:26:28] konsolebox: There are good uses for goto. The Linux kernel benefits a lot from it.
[14:29:10] garyserj: hah, linus should've written the goto statements considered harmful considered harmful paper!
[14:29:19] rkazak: has joined #ruby
[14:31:15] conta: has joined #ruby
[14:32:53] Xiti: has joined #ruby
[14:34:33] houhoulis: has joined #ruby
[14:37:42] mozzarella: still talking about goto?
[14:44:49] jready: has joined #ruby
[15:00:36] Xiti: has joined #ruby
[15:03:56] orbyt_: has joined #ruby
[15:06:18] conta: has joined #ruby
[15:13:40] Esa_: has joined #ruby
[15:14:34] dionysus69: has joined #ruby
[15:18:10] karapetyan: has joined #ruby
[15:18:17] Dimik: has joined #ruby
[15:20:43] justinweiss: has joined #ruby
[15:21:51] havenwood: garyserj: Ruby actually has GOTO. You just have to enable the SUPPORT_JOKE flag when you compile.
[15:23:09] avdi: has joined #ruby
[15:23:33] havenwood: garyserj: https://github.com/ruby/ruby/blob/14a3499c4f9dfc9ee102cbed5fe37481282f5f5a/compile.c#L6387-L6432
[15:23:43] havenwood: __label__ and __goto__
[15:24:35] havenwood: And as a bonus that gives you bitblt, for a bit of bacon, lettuce and tomato.
[15:27:22] Xiti: has joined #ruby
[15:31:09] s2013: has joined #ruby
[15:31:56] schaary: has joined #ruby
[15:32:13] adambeynon: has joined #ruby
[15:35:00] dipnlik: has joined #ruby
[15:37:49] dr3wo: has joined #ruby
[15:38:23] conta: has joined #ruby
[15:38:23] pizzaops: has joined #ruby
[15:41:33] ciscam: has joined #ruby
[15:44:00] lipoqil: has joined #ruby
[15:45:58] coderphive: has joined #ruby
[15:46:08] ciscam: has joined #ruby
[15:50:04] deimos: has joined #ruby
[15:53:39] charles81_: has joined #ruby
[15:54:11] clemens3: has joined #ruby
[15:54:13] manveru: has joined #ruby
[15:54:25] bcavileer: has joined #ruby
[15:56:32] roamingdog: has joined #ruby
[15:57:09] cschneid_: has joined #ruby
[15:57:17] roamingdog: has joined #ruby
[15:57:34] rfv: has joined #ruby
[15:58:07] roamingdog: has joined #ruby
[15:59:16] dinfuehr: has joined #ruby
[15:59:39] skmp: has joined #ruby
[15:59:46] houhoulis: has joined #ruby
[16:02:21] cstrahan: has joined #ruby
[16:06:02] ewilliam_: has joined #ruby
[16:07:25] BuildTheRobots: has joined #ruby
[16:08:11] jsrn: has joined #ruby
[16:08:30] pwnd_nsfw`: has joined #ruby
[16:19:08] conta: has joined #ruby
[16:26:07] cschneid_: has joined #ruby
[16:27:10] harrycs: has joined #ruby
[16:34:21] Yonk_: has joined #ruby
[16:42:44] codepete: has joined #ruby
[16:44:25] konsolebox: has joined #ruby
[16:45:40] Esa_: has joined #ruby
[16:46:05] barq: has joined #ruby
[16:46:54] danzilio: has joined #ruby
[16:49:03] Travis-42: has joined #ruby
[16:49:44] rabajaj: has joined #ruby
[16:50:09] Guest57056: has joined #ruby
[16:51:39] clemens3_: has joined #ruby
[16:51:53] Travis-42: has joined #ruby
[16:52:29] bga57: has joined #ruby
[16:54:32] nicoulaj: has joined #ruby
[16:55:09] jimeh: has joined #ruby
[16:55:36] Brak____________: has joined #ruby
[16:56:58] cadillac_: has joined #ruby
[16:57:33] SirFunk: has joined #ruby
[16:58:20] wolfshappen: has joined #ruby
[16:58:41] suukim: has joined #ruby
[16:59:20] dionysus69: has joined #ruby
[17:03:05] tekk: has joined #ruby
[17:03:17] mostlybadfly: has joined #ruby
[17:04:32] conta: has joined #ruby
[17:08:20] bluestar: has joined #ruby
[17:09:49] tvN: has joined #ruby
[17:10:06] BTRE: has joined #ruby
[17:11:28] pwnd_nsfw: has joined #ruby
[17:17:29] Ryzokuken: has joined #ruby
[17:17:49] Mike11: has joined #ruby
[17:21:54] harrycs: has joined #ruby
[17:23:54] harrycs: has joined #ruby
[17:28:43] za1b1tsu: has joined #ruby
[17:28:58] orbyt_: has joined #ruby
[17:29:59] harrycs: has joined #ruby
[17:32:26] dtzuzu: has joined #ruby
[17:33:43] JJonah: has joined #ruby
[17:38:03] Diabolik_: has joined #ruby
[17:39:41] mondongo: has joined #ruby
[17:42:36] RedNifre: has joined #ruby
[17:44:16] raggi: has joined #ruby
[17:44:17] RedNifre: Is there a way to chunk an array, e.g. [1,2,3,4,5].chunk(2) returns [[1,2],[3,4],[5]] and possibly even [1,2,3,4,5].chunk(2,0) -> [[1,2],[3,4],[5,0]] ?
[17:45:21] kies^: has joined #ruby
[17:47:46] RedNifre: okay, looks like .each_slice(2).to_a is what I'm looking for.
[17:51:26] micalexander: has joined #ruby
[17:52:19] r3my: has joined #ruby
[17:59:21] roamingdog: has joined #ruby
[18:04:34] za1b1tsu: has joined #ruby
[18:10:15] dr3wo: has joined #ruby
[18:13:37] plexigras: has joined #ruby
[18:16:04] Haradani: has joined #ruby
[18:24:17] conta: has joined #ruby
[18:37:11] sameerynho: has joined #ruby
[18:42:58] dr3wo: has joined #ruby
[18:45:38] jottr: has joined #ruby
[18:54:16] karapetyan: has joined #ruby
[19:06:32] yxhuvud: has joined #ruby
[19:10:59] nicesignal: has joined #ruby
[19:11:23] gr33n7007h: has joined #ruby
[19:12:01] phaul: has joined #ruby
[19:12:30] eckhardt: has joined #ruby
[19:17:47] conta: has joined #ruby
[19:20:07] raynold: has joined #ruby
[19:30:37] dr3wo: has joined #ruby
[19:32:33] cadillac_: has joined #ruby
[19:40:17] ciscam: has joined #ruby
[19:43:23] Xiti: has joined #ruby
[19:43:59] alfiemax: has joined #ruby
[19:44:39] alfiemax: has joined #ruby
[19:49:29] roamingdog: has joined #ruby
[20:00:13] dviola: has joined #ruby
[20:00:22] dviola: has joined #ruby
[20:04:40] weaksauce: has joined #ruby
[20:10:22] rkazak: has joined #ruby
[20:11:56] conta: has joined #ruby
[20:13:42] alfiemax: has joined #ruby
[20:22:17] tAn: has joined #ruby
[20:25:09] dstrunk: has joined #ruby
[20:28:04] karapetyan: has joined #ruby
[20:29:38] phaul: has joined #ruby
[20:32:18] tomphp: has joined #ruby
[20:33:57] karapetyan: has joined #ruby
[20:37:13] n0m4d1c: has joined #ruby
[20:41:47] ldepandis: has joined #ruby
[20:43:53] ineb: has joined #ruby
[20:44:20] lvzimmer: has joined #ruby
[20:44:27] alfiemax: has joined #ruby
[20:45:51] eckhardt_: has joined #ruby
[20:46:23] tomphp: has joined #ruby
[20:51:33] tomphp_: has joined #ruby
[20:52:50] rkazak: has joined #ruby
[20:53:58] Xiti: has joined #ruby
[20:54:37] dipnlik: has joined #ruby
[20:55:22] Immune: has joined #ruby
[20:56:03] Haradani: has joined #ruby
[20:57:10] bayprogrammer: has joined #ruby
[21:03:25] karapetyan: has joined #ruby
[21:06:19] conta: has joined #ruby
[21:08:30] Quentinius: has joined #ruby
[21:13:07] ged_: has joined #ruby
[21:14:50] mhoungbo1: has joined #ruby
[21:15:18] ccrow: has joined #ruby
[21:16:31] mlehrer: has joined #ruby
[21:19:12] r3m: has joined #ruby
[21:19:16] klaas: has joined #ruby
[21:19:39] mlehrer: has joined #ruby
[21:20:22] Xeago_: has joined #ruby
[21:20:26] Esa_: has joined #ruby
[21:20:53] ciscam: has joined #ruby
[21:22:27] dviola: has joined #ruby
[21:24:03] schneider-: has joined #ruby
[21:24:07] tekk: has joined #ruby
[21:24:46] cadillac_: has joined #ruby
[21:28:42] alfiemax: has joined #ruby
[21:34:17] ur5us: has joined #ruby
[21:44:53] meadmoon: has joined #ruby
[21:47:51] nibbo_: has joined #ruby
[21:47:52] volix: has joined #ruby
[21:48:22] jdeen_: has joined #ruby
[21:49:49] klaas: has joined #ruby
[21:53:41] flyhigh: has joined #ruby
[21:54:07] mnemon: has joined #ruby
[21:54:07] tekk: has joined #ruby
[21:54:08] roamingdog: has joined #ruby
[21:54:08] dr3wo: has joined #ruby
[21:54:08] eckhardt: has joined #ruby
[21:54:08] konsolebox: has joined #ruby
[21:54:08] GodFather: has joined #ruby
[21:54:08] marr: has joined #ruby
[21:54:08] psmolen: has joined #ruby
[21:54:08] herbmillerjr: has joined #ruby
[21:54:08] Asher: has joined #ruby
[21:54:08] aspiers: has joined #ruby
[21:54:08] rwb: has joined #ruby
[21:54:08] d^sh: has joined #ruby
[21:54:08] mkaito_: has joined #ruby
[21:54:08] ohcibi: has joined #ruby
[21:54:08] thinkpad: has joined #ruby
[21:54:08] phoo1234567: has joined #ruby
[21:54:08] tris: has joined #ruby
[21:54:08] zumbi: has joined #ruby
[21:54:08] eam: has joined #ruby
[21:54:38] mhoungbo1: has joined #ruby
[21:54:54] cibs: has joined #ruby
[21:54:56] DTZUZO: has joined #ruby
[21:55:06] zautomata3: has joined #ruby
[21:55:47] armyriad: has joined #ruby
[21:56:01] leonthemisfit: has joined #ruby
[21:56:01] leonthemisfit: has joined #ruby
[21:56:07] clemens3_: has joined #ruby
[21:56:23] psmolen: has joined #ruby
[21:56:25] giraffe: has joined #ruby
[21:56:34] alfiemax: has joined #ruby
[21:56:35] marr: has joined #ruby
[21:57:20] rwb: has joined #ruby
[21:57:45] d^sh: has joined #ruby
[21:58:12] n0m4d1c: has joined #ruby
[21:58:35] thinkpad: has joined #ruby
[21:58:39] dr3wo: has joined #ruby
[22:00:35] eblip: has joined #ruby
[22:00:45] tris-: has joined #ruby
[22:01:31] nicesignal: has joined #ruby
[22:02:31] tekk: has joined #ruby
[22:02:34] c0ncealed1: has joined #ruby
[22:05:15] cadillac_: has joined #ruby
[22:08:07] lvzimmer: has left #ruby: ()
[22:09:13] pwnd_nsfw`: has joined #ruby
[22:10:46] jtms: has joined #ruby
[22:11:15] nowhere_man: has joined #ruby
[22:14:31] jtms: has left #ruby: ("Leaving")
[22:17:55] orbyt_: has joined #ruby
[22:20:05] alfiemax: has joined #ruby
[22:20:31] TinkerT: has joined #ruby
[22:22:02] conta: has joined #ruby
[22:26:18] RougeR: has joined #ruby
[22:27:25] aaronm04: has joined #ruby
[22:50:55] alfiemax: has joined #ruby
[23:00:18] mhoungbo1: has joined #ruby
[23:03:13] sanscoeur: has joined #ruby
[23:04:52] jeffreylevesque: has joined #ruby
[23:09:51] amar: has joined #ruby
[23:14:43] apeiros: has joined #ruby
[23:16:25] conta: has joined #ruby
[23:21:47] nowhere_man: has joined #ruby
[23:22:04] alfiemax: has joined #ruby
[23:24:20] schneider-: has joined #ruby
[23:24:29] hinbody: has joined #ruby
[23:24:41] hinbody: has left #ruby: ()
[23:39:53] hph^: has joined #ruby
[23:45:31] t0adst00l: has joined #ruby
[23:51:03] ciscam: has joined #ruby
[23:56:09] apeiros: has joined #ruby
[23:56:34] alfiemax: has joined #ruby