<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
<baweaver>
garyserj: you don't need it
cschneid_ has quit [Remote host closed the connection]
<baweaver>
that's what exit and abort are for
<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
<baweaver>
This is what modules, classes, and methods are for.
gizmore has joined #ruby
gheegh has joined #ruby
<baweaver>
goto was an old variant of flow control from before such things really existed
<baweaver>
so to superimpose it into a language which has these concepts is not a great idea
<garyserj>
well as I showed, I managed without a goto, by using an extra nesting of if statement
<baweaver>
What's your actual code?
gheegh has quit [Client Quit]
<garyserj>
Gotos can be used to implement many things.. they can be used as an alternative to methods.
<garyserj>
I only have the simplified example. (which is actually clearer)
<garyserj>
but I didn't use a goto as an alternative to a method
<garyserj>
The ban on Gotos is actually more controversial than you think
<baweaver>
It
<baweaver>
's not, it's just bad design
<garyserj>
There is a paper called "Goto considered harmful, considered harmful"
<garyserj>
which states quite rightly that no more should an entire word be considered a bad thing.. like banning a word from a language.
<garyserj>
it can be used or abused.
<baweaver>
and you're abusing it in a language which has features which invalidate its use
<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
kapil___ has joined #ruby
gheegh has joined #ruby
<garyserj>
well I didn't use it, I used an extra nesting of if, though it is a bit uglier.
gizmore|2 has quit [Ping timeout: 260 seconds]
gheegh has quit [Client Quit]
<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
<garyserj>
'tended'
<hays>
at least that's what I remember when I read the paper--its been a while
<garyserj>
yeah and somebody that knows about the ugly uses of goto can use it in an ok manner.
<garyserj>
not an ugly usage.
<baweaver>
garyserj: What's the actual code?
<garyserj>
I only have the simplified version at the moment, but it is totally clear
<garyserj>
what's the problem with it?
<baweaver>
because I guarantee you there's a better more testable way to do it
<garyserj>
i'm shown you a very simple example why can't you use that?
<baweaver>
My problem is you're coming across as trolling, quite frankly.
gheegh has joined #ruby
<garyserj>
ok well let's not have the discussion about goto then.
<baweaver>
It's not even really a discussion. You provided a sample which doesn't actually show your usecase
<baweaver>
and now insist it's valid applied to a larger application.
gheegh has quit [Client Quit]
<hays>
i prefer the below, although if A()==true was cheap, I'd consider just flattening it a bit and just having 3 cases
cschneid_ has joined #ruby
<baweaver>
we assert that there are language features that make the usage of such completely unnecessary
<garyserj>
baweaver: okay.
chocoelho has joined #ruby
<baweaver>
You're likely using it for flow control in a single action of a Sinatra controller of sorts.
<garyserj>
hays: yes I thought of that too, that's a good idea
<baweaver>
Most conditional logic can be refined further into classes and modules for easier testing and reuse
<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
<hays>
baweaver: i remember seeeing examples of that in Strousoups old C++ book and I didn't really get it
gheegh has joined #ruby
<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
<hays>
how might one eliminate conditional logic in the simple case we're talking about here
<baweaver>
It depends, which is why I keep asking for what the actual code is
white_lilies has quit [Quit: WeeChat 2.1]
gheegh has quit [Client Quit]
<baweaver>
You cannot derive the concern of the application from names like A, B, yyy, and zzz
<baweaver>
So using them to make an assertion about the validity of goto is an architectural sham.
<garyserj>
hays: do you think it matters what A,B,yyy,zzz are?
<garyserj>
it's not to do with testing something that would or could be in the URL anyway.
<garyserj>
so it's not like more routes would make a difference.
<hays>
garyserj: it might. but I actually think the structured version is cleaner than using goto
<baweaver>
Are they routed objects based on params, are they queries, url segments, child objects? It could be a lot of things.
<garyserj>
hays: with three ifs, I think so. With the extra nesting I don't think so.. though we disagree there with the latter.
<baweaver>
What is the exact task you're trying to accomplish?
<baweaver>
Because this veers very heavily into the XY problem
<baweaver>
!xy
<baweaver>
?xy
<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
<baweaver>
You have a solution you want, and are fixated on it to the detriment of all possible better solutions.
<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.
<hays>
I think "The Practice of Programming" would suggest flattening the logic
<baweaver>
It's because it's so unnecessary in the language that I'm trying to warn you of it
<hays>
Kernighan is pretty old school though
headius_ is now known as headius
<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
<baweaver>
State machines are a hard problem to solve for.
<garyserj>
hays: spaghetti like and nested ifs are very different things.. nested ifs, while they can be ugly, are technically not spaghetti code.
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<garyserj>
spaghetti code would be Gotos jumping all over the place.
<garyserj>
no gotos and it may still be ugly though technically not spaghetti code, just ugly code ;-)
<baweaver>
I'd argue that more than a few nested ifs are also bad code.
Yxhuvud has joined #ruby
<baweaver>
It means your object or method knows too much and should likely be broken down more.
<baweaver>
That primarily gets into Metz's rule and Single Responsibility Principle
<baweaver>
Though the Metz rule can be a bit extreme.
bzb has joined #ruby
<hays>
the number of states often ends up going up by 2^n
<hays>
logic ends up being the only way to combat that
mroutis has joined #ruby
<garyserj>
you could flatten nested ifs into multiple ones with longer conditionals.. How are you solving that with more methods?
<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.
<garyserj>
hays: yeah I don't think there is any getting around logic like that.
<baweaver>
It depends so much on what you're expressing
<garyserj>
methods have nothing to do with it
<baweaver>
and that's the dig, you cannot abstractly capture that level of nuance with fake names and short examples.
<baweaver>
The biggest problem behind all of this is it's absolutely impossible to test.
<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.
<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).
gheegh has joined #ruby
<baweaver>
and once you get into larger applications that are customer facing or mission critical?
RyanMcCoskrie has quit [Ping timeout: 256 seconds]
gheegh has quit [Client Quit]
<garyserj>
baweaver: nobody is suggesting not using methods and nobody is suggeseting having 100 lines of code not broken into a different method.
<hays>
and yet so much safety related code is nested logic and state machines
conta has joined #ruby
<garyserj>
methods have nothing to do with this, it's a complete red herring
<garyserj>
hays: I agree
mroutis has quit [Remote host closed the connection]
rkazak has joined #ruby
gheegh has joined #ruby
<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/
ur5us has joined #ruby
<baweaver>
I've worked on the same code. That doesn't make it good or even acceptable.
gheegh has quit [Client Quit]
<baweaver>
Especially around SCADA and controllers in general, then even further back into RPG and COBOL era
<hays>
oh yeah its all a nightmare and a big false sense of security
<baweaver>
If you wanted to change something you were basically screwed.
<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
<baweaver>
Thing is, we've moved on as an industry from a lot of it to a lot more testable interfaces.
conta has quit [Ping timeout: 268 seconds]
ur5us has quit [Ping timeout: 240 seconds]
mroutis has joined #ruby
<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
<baweaver>
param wise, unless it's an index with a search action that's a hint you need more routes.
<baweaver>
primarily oriented towards resources you need to express
jready has joined #ruby
<baweaver>
We had one recently where someone loaded everything into '/' using params for dispatch, that's not ok.
<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
<hays>
well sure you're talking about REST
<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.
gheegh has joined #ruby
gheegh has quit [Client Quit]
<garyserj>
the problem isn't solved by multiple routes.
<baweaver>
A lot of it is that things just do too much and become impossible to test or reason about after a while
<baweaver>
garyserj: OH! So there is context
<baweaver>
and what do you know, context changes concerns
<garyserj>
well you keep being very presumptuous about the code
<garyserj>
and each time, wrongly.
<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?
gheegh has joined #ruby
<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?
gheegh has quit [Client Quit]
<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.
<garyserj>
I think what hays said, of flattening the ifs, is perfectly good. And totally based on my simplified example.
<garyserj>
adding all that detail you wanted hasn't helped anybody.
Haradani has joined #ruby
Haradani has quit [Remote host closed the connection]
<garyserj>
and you still accuse me of trolling? I only continued the discussion with you because you kept requesting that I continue it.
ryzokuken has joined #ruby
Haradani has joined #ruby
rkazak has quit [Ping timeout: 264 seconds]
<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
<garyserj>
heh
<hays>
it has a similar problem as goto
<garyserj>
i think that is the ugliest!
gheegh has joined #ruby
roamingdog has joined #ruby
<hays>
it works sometimes but yes i agree
<garyserj>
way way back I learnt the harm of over-modularisation
gheegh has quit [Client Quit]
gheegh has joined #ruby
jready has quit [Remote host closed the connection]
gheegh has quit [Client Quit]
Haradani has quit [Remote host closed the connection]
<mroutis>
what's going on?
Haradani has joined #ruby
gheegh has joined #ruby
<hays>
garyserj wants goto :)
gheegh has quit [Client Quit]
za1b1tsu has joined #ruby
Dimik has quit [Ping timeout: 240 seconds]
Haradani has quit [Remote host closed the connection]
AJA4350 has quit [Remote host closed the connection]
Haradani has joined #ruby
gheegh has joined #ruby
<mroutis>
and what about the routes and REST part, hays? I'm a little bit lost, hehe
<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
<baweaver>
Pretty much, then laying out normal concerns people tend to reach for it in and how to get around it.
<mroutis>
makes sense
<baweaver>
...which apparently was taken as an answer
houhoulis has quit []
cadillac_ has joined #ruby
gheegh has joined #ruby
RougeR has quit [Ping timeout: 240 seconds]
gheegh has quit [Client Quit]
gheegh has joined #ruby
gheegh has quit [Client Quit]
jottr has joined #ruby
gheegh has joined #ruby
gheegh has quit [Client Quit]
conta has joined #ruby
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
jottr has quit [Ping timeout: 240 seconds]
Yxhuvud has joined #ruby
gheegh has joined #ruby
gheegh has quit [Client Quit]
conta has quit [Ping timeout: 256 seconds]
gheegh has joined #ruby
chocoelho has quit [Quit: Konversation terminated!]
gheegh has quit [Client Quit]
gheegh has joined #ruby
gheegh has quit [Client Quit]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<hays>
reading the Dijkstra/Rubin correspondance is kinda funny
jsrn has quit [Ping timeout: 265 seconds]
jsrn has joined #ruby
<hays>
i should write a paper: for loops considered harmful :)
arescorpio has joined #ruby
gheegh has joined #ruby
gheegh has quit [Client Quit]
<garyserj>
somebody might make a response e.g. there is a paper called "goto statements considered harmful, considered harmful"
za1b1tsu has quit [Ping timeout: 264 seconds]
gheegh has joined #ruby
gheegh has quit [Client Quit]
conta has joined #ruby
x77686d has joined #ruby
conta has quit [Ping timeout: 256 seconds]
bzb has quit [Quit: Leaving]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
RyanMcCoskrie has joined #ruby
<hays>
seriously, dijkstra skewers that guy
<hays>
his answer avoids goto and does not waste a single bit of memory or cpu cycle
<hays>
and is incredibly clear
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<hays>
not exactly in the style of web code written in 2018 but hey
Yxhuvud has joined #ruby
<hays>
i might better say code written for distributed architectures
endemic has quit [Ping timeout: 276 seconds]
cschneid_ has quit [Remote host closed the connection]
konsolebox has quit [Ping timeout: 240 seconds]
pwnd_nsfw has quit [Read error: Connection reset by peer]
face has quit [Read error: Connection reset by peer]
conta has joined #ruby
face has joined #ruby
pwnd_nsfw has joined #ruby
konsolebox has joined #ruby
conta has quit [Ping timeout: 248 seconds]
matled has quit [Remote host closed the connection]
matled has joined #ruby
roamingdog has quit [Read error: Connection reset by peer]
Prira_ has quit [Remote host closed the connection]
klaas has quit [Read error: Connection reset by peer]
herbmillerjr has quit [Excess Flood]
roamingdog has joined #ruby
herbmillerjr has joined #ruby
mlehrer has quit [Ping timeout: 260 seconds]
armyriad has quit [Ping timeout: 264 seconds]
klaas has joined #ruby
segy has quit [Ping timeout: 260 seconds]
dviola has quit [Ping timeout: 260 seconds]
Prira has joined #ruby
mlehrer has joined #ruby
nowhere_man has joined #ruby
_zach has quit [Ping timeout: 260 seconds]
_zach has joined #ruby
Esa_ has quit []
psmolen has quit [Ping timeout: 265 seconds]
psmolen has joined #ruby
segy has joined #ruby
armyriad has joined #ruby
mroutis has quit [Remote host closed the connection]
modin has quit [Ping timeout: 276 seconds]
modin has joined #ruby
arescorpio has quit [Quit: Leaving.]
ryzokuken has quit [Remote host closed the connection]
nowhere_man has quit [Remote host closed the connection]
nowhere_man has joined #ruby
jottr has joined #ruby
alfiemax has joined #ruby
jottr has quit [Ping timeout: 240 seconds]
govg has quit [Quit: leaving]
nadir has joined #ruby
alfiemax has quit [Remote host closed the connection]
nima_m_ has joined #ruby
apparition has joined #ruby
webhat has quit [Read error: Connection reset by peer]
webhat has joined #ruby
nima_m_ has quit [Read error: Connection reset by peer]
pabs has quit [Ping timeout: 240 seconds]
pabs has joined #ruby
hanmac has quit [Ping timeout: 268 seconds]
x77686d has quit [Quit: x77686d]
conta has joined #ruby
conta has quit [Ping timeout: 240 seconds]
ropeney has quit [Remote host closed the connection]
apparition has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<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.
yaiyaichu has quit [Read error: Connection reset by peer]
yaiyaichu has joined #ruby
karapetyan has quit [Ping timeout: 260 seconds]
coderphive has joined #ruby
yaiyaichu has quit [Read error: Connection reset by peer]
yaiyaichu has joined #ruby
jottr has joined #ruby
biberu has joined #ruby
coderphive has quit [Ping timeout: 240 seconds]
jottr has quit [Ping timeout: 240 seconds]
cadillac_ has quit [Ping timeout: 268 seconds]
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cadillac_ has joined #ruby
eckhardt has joined #ruby
yaiyaichu has quit [Quit: leaving]
Sembei has quit [Ping timeout: 264 seconds]
luna_x[m] has joined #ruby
za1b1tsu has joined #ruby
dionysus69 has joined #ruby
Sembei has joined #ruby
apeiros has quit [Remote host closed the connection]
apeiros has joined #ruby
jamesaxl has joined #ruby
marr has joined #ruby
clemens3 has joined #ruby
TinkerT has quit [Read error: Connection reset by peer]
TinkerT has joined #ruby
sameerynho has joined #ruby
RougeR has joined #ruby
schleppel has joined #ruby
kent\n has quit [Quit: No Ping reply in 180 seconds.]
kent\n has joined #ruby
RyanMcCoskrie has quit [Remote host closed the connection]
conta has joined #ruby
conta has quit [Ping timeout: 260 seconds]
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
venmx has joined #ruby
rabajaj has quit [Ping timeout: 256 seconds]
dionysus69 has quit [Ping timeout: 240 seconds]
DTZUZO has quit [Ping timeout: 264 seconds]
DTZUZO has joined #ruby
alex`` has quit [Ping timeout: 268 seconds]
alex`` has joined #ruby
za1b1tsu has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
nadir has quit [Quit: Connection closed for inactivity]
leitz has joined #ruby
leitz has left #ruby [#ruby]
karapetyan has joined #ruby
dionysus69 has joined #ruby
karapetyan has quit [Ping timeout: 260 seconds]
jenrzzz has quit [Ping timeout: 248 seconds]
blackmesa has joined #ruby
blackmesa has quit [Client Quit]
tomphp has joined #ruby
jottr has joined #ruby
za1b1tsu has joined #ruby
jottr has quit [Ping timeout: 264 seconds]
rabajaj has joined #ruby
Mike11 has joined #ruby
dionysus69 has quit [Ping timeout: 260 seconds]
conta has joined #ruby
anisha has joined #ruby
sameerynho has quit [Ping timeout: 260 seconds]
faces has joined #ruby
anisha_ has joined #ruby
conta has quit [Read error: Connection reset by peer]
klaas has quit [Read error: Connection reset by peer]
CBebop has quit [Ping timeout: 240 seconds]
yosafbridge has quit [Ping timeout: 240 seconds]
conta has joined #ruby
CBebop has joined #ruby
klaas has joined #ruby
yosafbridge has joined #ruby
anisha has quit [Ping timeout: 240 seconds]
face has quit [Ping timeout: 240 seconds]
armyriad has quit [Ping timeout: 260 seconds]
brodul has quit [Ping timeout: 240 seconds]
armyriad has joined #ruby
brodul has joined #ruby
clemens3 has quit [Ping timeout: 240 seconds]
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
RougeR has quit [Ping timeout: 264 seconds]
guille-moe has joined #ruby
s2013 has joined #ruby
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #ruby
jsrn has quit [Ping timeout: 260 seconds]
jsrn has joined #ruby
marr has quit [Ping timeout: 240 seconds]
venmx has quit [Ping timeout: 268 seconds]
t0adst00l has joined #ruby
govg has joined #ruby
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #ruby
soniya29 has joined #ruby
soniya29_ has joined #ruby
podman has quit []
podman has joined #ruby
rabajaj has quit [Ping timeout: 240 seconds]
guille-moe has quit [Quit: guille-moe]
rabajaj has joined #ruby
ellcs has joined #ruby
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #ruby
cjs226 has quit []
cjs226 has joined #ruby
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #ruby
kapil___ has quit []
kapil___ has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jxf has quit []
jxf has joined #ruby
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #ruby
conta1 has joined #ruby
s2013 has joined #ruby
s2013 has quit [Client Quit]
jottr has joined #ruby
nickjj has quit [Read error: Connection reset by peer]
<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
marr has joined #ruby
Tony-St4rk has quit []
nickjj has joined #ruby
Tony-St4rk has joined #ruby
sanjeevkumar has joined #ruby
<hays>
as for common sense, goto was in pretty widespread use at the time
rabajaj has quit [Ping timeout: 260 seconds]
InfinityFye has joined #ruby
InfinityFye has left #ruby [#ruby]
kireevco has joined #ruby
dr3w_ has joined #ruby
boxrick has quit []
boxrick has joined #ruby
jottr has quit [Ping timeout: 264 seconds]
AJA4350 has joined #ruby
jabreity has quit []
jabreity has joined #ruby
andersh has quit []
andersh has joined #ruby
solidsnack has quit []
cttttt has quit []
solidsnack has joined #ruby
cttttt has joined #ruby
pwillard has quit []
rabajaj has joined #ruby
pwillard has joined #ruby
peteretep has quit []
peteretep has joined #ruby
conta1 has quit [Remote host closed the connection]
rabajaj has quit [Ping timeout: 260 seconds]
<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
<Mike11>
currently I am doing something like this:
<Mike11>
new_str = String.new str
<Mike11>
new_str[range] = replacement
<Mike11>
return new_str
<Mike11>
but I feel like I am overcomplicating it? is there a more brief way?
shwouchk has quit []
shwouchk has joined #ruby
<Mike11>
so, my question is: is there a method that acts like String#[] but returns a new string instead of mutating the current instance?
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #ruby
conta1 has joined #ruby
conta1 has quit [Client Quit]
AndyWojo has quit []
AndyWojo has joined #ruby
t0adst00l has quit [Ping timeout: 255 seconds]
s2013 has joined #ruby
MoskitoHero has joined #ruby
<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.
GodFather has quit [Quit: Ex-Chat]
GodFather has joined #ruby
conta has quit [Ping timeout: 256 seconds]
rann has quit []
rann has joined #ruby
weaksauce has quit [Ping timeout: 264 seconds]
<konsolebox>
> p = "abc"[1]; puts p.object_id; puts p.dup.object_id
<konsolebox>
>> p = "abc"[1]; puts p.object_id; puts p.dup.object_id
<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
hahahahah has quit [Changing host]
hahahahah has joined #ruby
DTZUZO has quit [Read error: Connection reset by peer]
<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?
<konsolebox>
Mike11: String#[] returns a new string as I observe
DTZUZO has joined #ruby
<Mike11>
konsolebox: sorry, I mean String#[]=
<Mike11>
I just want to return a new String that contains the same content of a frozen string after replacing a range
<lupine>
hahahahah: /\A([^\?].*)/
armyriad has quit [Read error: Connection reset by peer]
<lupine>
you can use irb to get an interactive shell
<Mike11>
something like this:
<Mike11>
return new_str
<Mike11>
new_str[range] = some_other_str
<Mike11>
new_str = str.dup
armyriad has joined #ruby
<hahahahah>
lupine: awesomenesss thanks :)))
<konsolebox>
Mike11: I see. Then why not string.dup[range]= some_other_string?
<lupine>
(note that I'm not familiar with logstash at all)
<konsolebox>
wait
<Mike11>
konsolebox: the whole statement evaluates to some_other_string
<konsolebox>
yeah yeah
<Mike11>
konsolebox: seems like the most brief way, no problem, thank you for your help :)
sanjeevkumar has quit [Remote host closed the connection]
<hahahahah>
'/directory/sub/action.php?var=1&var3=dsgadsa '.gsub(/\A([^\?].*)/, '') => "" (i guess is not gsub... :o )
<hahahahah>
no sorry.. i meant: statement;statement2
<hahahahah>
:)
mlehrer has joined #ruby
ellcs has quit [Ping timeout: 264 seconds]
<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.
anisha_ has quit [Quit: This computer has gone to sleep]
<hahahahah>
|: u are complicating the problem.. is way more simple
anisha_ has joined #ruby
<hahahahah>
i just needed to put too statements of ruby in one single line.. lol
anisha_ has quit [Remote host closed the connection]
Sina has quit []
Sina has joined #ruby
dr3w_ has joined #ruby
dr3w_ has quit [Client Quit]
KnownSyntax has quit []
<konsolebox>
hahahahah: try to give an example then, and elaborate what your target goal is
KnownSyntax has joined #ruby
<hahahahah>
Ruby exception occurred: undefined method `split' for nil:NilClass how can i avoid this? :o or check if the string exists?
kspencer has quit []
kspencer has joined #ruby
dr3w_ has joined #ruby
Mike11 has quit [Ping timeout: 260 seconds]
<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])'
<konsolebox>
hahahahah: looks like you have to check if get("request") returns a string or not
Sembei has quit [Ping timeout: 256 seconds]
MyMind has joined #ruby
<hahahahah>
konsolebox: stupid bot. |:
rippa has joined #ruby
<konsolebox>
hahahahah: me stupid? sure, if that makes you feel smarter.
rabajaj has joined #ruby
hahahahah has quit [Quit: Page closed]
yokel has quit [Ping timeout: 240 seconds]
rabajaj has quit [Read error: Connection reset by peer]
soniya29_ has quit [Ping timeout: 240 seconds]
soniya29 has quit [Ping timeout: 240 seconds]
psychicist__ has joined #ruby
cschneid_ has joined #ruby
DLSteve has joined #ruby
cschneid_ has quit [Ping timeout: 264 seconds]
cschneid_ has joined #ruby
raynold has quit [Quit: Connection closed for inactivity]
cschneid_ has quit [Ping timeout: 264 seconds]
epochwolf has quit []
epochwolf has joined #ruby
gr33n7007h has joined #ruby
gr33n7007h is now known as al2o3-cr
hph^ has joined #ruby
conta has quit [Ping timeout: 268 seconds]
tvN has joined #ruby
tvN has quit [Quit: Page closed]
chocoelho has quit [Quit: Konversation terminated!]
<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.
<konsolebox>
There are good uses for goto. The Linux kernel benefits a lot from it.
<garyserj>
hah, linus should've written the goto statements considered harmful considered harmful paper!
rkazak has joined #ruby
<konsolebox>
+1
conta has joined #ruby
Xiti has quit [Quit: Xiti]
Xiti has joined #ruby
houhoulis has joined #ruby
conta has quit [Ping timeout: 240 seconds]
<mozzarella>
jesus
<mozzarella>
still talking about goto?
apparition has quit [Quit: Bye]
<konsolebox>
goto ∞;
jready has joined #ruby
Sina has quit [Quit: Connection closed for inactivity]
Xiti has quit [Quit: Xiti]
Xiti has joined #ruby
orbyt_ has joined #ruby
conta has joined #ruby
conta has quit [Ping timeout: 264 seconds]
Esa_ has joined #ruby
dionysus69 has joined #ruby
jready has quit []
karapetyan has joined #ruby
Dimik has joined #ruby
justinweiss has quit []
justinweiss has joined #ruby
<havenwood>
garyserj: Ruby actually has GOTO. You just have to enable the SUPPORT_JOKE flag when you compile.
<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]] ?
dipnlik has quit [Quit: Connection closed for inactivity]
kies^ has joined #ruby
<RedNifre>
okay, looks like .each_slice(2).to_a is what I'm looking for.
micalexander has joined #ruby
za1b1tsu has quit [Quit: WeeChat 2.1]
r3my has quit []
BTRE has quit [Quit: Leaving]
r3my has joined #ruby
roamingdog has joined #ruby
roamingdog has quit [Ping timeout: 248 seconds]
za1b1tsu has joined #ruby
ccrow has quit [Remote host closed the connection]