I am parsing string records in this form:
description: double/double/double
for ex.:
item description: 0.4/8/-24.66
Each record should result in an object:
new MyObj("first item", 0.4, 2.4, -24.66)
I could easily do this with a regular expression and a procedural approach, but the resulting code is error-prone and rather ugly (at least from a functional point of view).
How can this be accomplished in a more elegant way?
Or you can just create a simple parser function
string->MyObjlike this:(update: I guessed that records were separated by a new-line or something like that and were split into a list. On the second thought, there’s nothing like that in your question…)