On Saturday 17 July 2010 16:21:04 Michael Koehmstedt wrote: > Thanks for the informative reply. > > I am getting a run-time error with to!int(str). Apparently to!() seems to > only support one-way converting other types to strings. That is part of > the reason why I was getting so confused in figuring out how to read in an > integer value. But you guys pointed me towards parse!() and that does work > with string->int.
Hmm... to!int(str) seems to be working for me. The issue is probably that when doing such a conversion, the _whole_ string must be convertable. So, no extra whitespace or whatnot. If you're looking to take multiple values out of a particular string or you might have whitespace in it, parse() is a better choice. But to() should work just fine as long as the string is exactly convertable to the type. As I understand it, to() should be able to convert pretty much anything to anything as long as the type has the appropriate conversion functions defined. - Jonathan M Davis