SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: How to bail?
-
Nov 6, 2005, 21:17 #1
- Join Date
- Jun 2003
- Location
- Iowa, USA
- Posts
- 3,749
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How to bail?
Needed to exit early in a shell script I wrote in Ruby. I ended up with:
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.
-
Nov 7, 2005, 00:52 #2
- Join Date
- Jun 2004
- Location
- Stockholm, Sweden
- Posts
- 148
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well there is the Process.exit method. It basically does what you're doing except you don't have to type it all out.
PHP 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
-
Nov 7, 2005, 09:03 #3
- Join Date
- Jun 2004
- Location
- California
- Posts
- 440
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I have a question also, similar to this. How can I quickly exit out of a method? Can I just do:
Code:return someting
EDIT: Sorry to kinda hijack your thread, i assume your question is answered
-
Nov 12, 2005, 18:51 #4
- Join Date
- Jun 2003
- Location
- Iowa, USA
- Posts
- 3,749
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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.
-
Nov 12, 2005, 21:20 #5
- Join Date
- Jun 2004
- Location
- California
- Posts
- 440
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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