Keith Devens .com |
Saturday, July 5, 2008 | ![]() |
| Linux is only free if your time has no value – Jamie Zawinski | ||
|
| ← Lethon | Kaliban's Class Loot Lists → |

Adam Vandenberg (http://adamv.com/) wrote:
revence 27 wrote:
The problem is not the nitification of an error, which should happen in any self-respecting API. You are doing a bad thing -- and should be notified -- if you access out of bounds.
So, it is not the error that's the prob. It's the Exception. The problem is that those languages throw on errors, which is very ungood. That's why Py had str.index, and str.find. One throws, another whispers.
Down with Exceptions. Down with Exceptions! DOWN WITH EXCEPTIONS! (Join in, all of you! Join! Join the Revolution!) Down with EXCEPTIONS!
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):
Generated in about 0.124s.
(Used 8 db queries)

Dumb indeed.
public static class Strings {
/// <summary>
/// Returns the substring with the first min(charcount, s.Length)
/// characters from string s
/// </summary>
public static string First(string s, int charcount)
{
if (s == null) return String.Empty;
return s.Substring(0, Math.Min(s.Length, charcount));
}
}
(Editors note: code reformatted slightly to not bust my layout)