< :the previous in number
^ :the list in numerical order
> :the next in number
P :the previous (in thread)
N :the next (in thread)
|<:the top of this thread
>|:the next thread
^ :the parent (reply-to)
_:the child (an article replying to this)
>:the elder article having the same parent
<:the youger article having the same parent
---:split window and show thread lists
| :split window (vertically) and show thread lists
~ :close the thread frame
.:the index
..:the index of indices
Jamis Buck wrote:
> GGarramuno wrote:
>
>> 1) I assume the question will be no, but is it possible to evaluate a
>> piece of proc code for syntax errors? That is, I have a construct of
>> the form:
>>
>> text = "some text coming from somewhere"
>> code = proc { text }
>>
>> I'd like to know whether text is valid ruby code (syntactically),
>> without having to run the proc. In perl, this would be done by
>> running eval on the code, as perl compiles to bytecode the proc even
>> if not running it.
>> But in ruby, it seems the proc is not "compiled" until run. Is there
>> any work-around for this?
>
> If you pass the code to eval, you can then test for a SyntaxError
> exception, like so:
>
> text = "some text coming from somewhere"
> begin
> eval "text"
> rescue SyntaxError => e
> # do something when it has a syntax error
> end
>
But that would execute the code, wouldn't it?