Needed to exit early in a shell script I wrote in Ruby. I ended up with:
This is working fine, but I think I might be missing some other simpler means of accomplishing this.Code:raise SystemExit.new(status=0)
| SitePoint Sponsor |
Needed to exit early in a shell script I wrote in Ruby. I ended up with:
This is working fine, but I think I might be missing some other simpler means of accomplishing this.Code:raise SystemExit.new(status=0)
Jason Sweat ZCE - jsweat_php@yahoo.com
Book: PHP Patterns
Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
Detestable (adjective): software that isn't testable.
Well there is the Process.exit method. It basically does what you're doing except you don't have to type it all out.
is the same asPHP Code:exit(0)
PHP Code:raise SystemExit.new(status=0)
If there is a way to overcome the suffering, there is no need to worry; if there is no way to overcome the suffering, there is no point to worry.
- Shantideva



I have a question also, similar to this. How can I quickly exit out of a method? Can I just do:
such as C/C++ or PHP?Code:return someting
EDIT: Sorry to kinda hijack your thread, i assume your question is answered
Sorry for the late response. Yes, return exits a function/method at the point where it is encountered:Originally Posted by xmitchx
Code:>> def foo >> "bar" >> end => nil >> def foo2 >> return "zaa" >> "bar" >> end => nil >> ?> foo => "bar" >> ?> foo2 => "zaa" >>
Jason Sweat ZCE - jsweat_php@yahoo.com
Book: PHP Patterns
Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
Detestable (adjective): software that isn't testable.



Wonderful. I never have had the need [yet] to use this but I think I needed it at some time and decided to just use a simple if then to bypass it.
But now that I know this, im happy![]()
Bookmarks