9

I am trying to post on stackoverflow site, but keep getting "This post does not meet our quality standards." Yes I am new. What am I doing wrong?

I am starting learn Ruby, need some help with the include? method.

The below code works just fine:

x = 'ab.c'
if x.include? "." 
  puts 'hello'
else
  puts 'no'
end

But when I code it this way:

x = 'ab.c'
y = 'xyz'
if x.include? "." || y.include? "."
  puts 'hello'
else
  puts 'no'
end

If gives me error when I run it:

test.rb:3: syntax error, unexpected tSTRING_BEG, expecting keyword_then or ';' o
r '\n'
if x.include? "." || y.include? "."
                                 ^
test.rb:5: syntax error, unexpected keyword_else, expecting end-of-input

Is this because the include? method cannot have handle logic operator?

Thanks

3
  • 1
    Well this is an interesting example. I'm going to link you here, but I'm not sure that's going to be very helpful for you. Try removing the "thanks"? I mean, I'd upvote this as is, but still... I hope we're still allowed to thank people.
    – user206222
    Apr 20, 2013 at 23:52
  • I'm guessing the lower-case letter following a question mark, twice, is a negative indicator. A false positive in this case, as it happens. Apr 20, 2013 at 23:55
  • 1
    Putting "include?" as include? might help.
    – Jeremy
    Apr 21, 2013 at 0:08

2 Answers 2

8

Hmm...

You should be getting this error:

These words are not allowed in titles: 'help with'

(I'm assuming the first line you quoted was your title; if you used a different title, please include that too)

The title you've written is not very descriptive of your question. If possible, try to summarize your question when writing the title, including as much specific information as you can manage while keeping it brief. I would recommend something like the following:

What causes "unexpected tSTRING_BEG, expecting keyword_then or ';' or '\n'" when trying to use a second include? condition?

If you're not seeing the error message I posted above, please clarify the title and tags you're using when trying to post, and I'll dig into this further.

0

Thanks guys! Changed the lower case to capitalize in my title and voila, it went through. I was just trying to keep it as close to the ruby syntax as possible

Thanks!

1
  • 2
    Ah, your title was different...
    – Shog9
    Apr 21, 2013 at 0:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .