Why Array#include? not working withone liner integer arrays?

I was trying to write a one liner with integer array using
array#include?,which is not working.But the same is good with
character/string array.

C:>irb
irb(main):001:0> a=[1,2,3]
=> [1, 2, 3]
irb(main):002:0> a.include?(1)
=> true
irb(main):003:0> a.include?(5)
=> false
irb(main):004:0> [1,2,3].inculde?(1)
NoMethodError: undefined method inculde?' for [1, 2, 3]:Array from (irb):4 from C:/Ruby193/bin/irb:12:in
irb(main):007:0> b=[".vbs",".exe",".h"]
=> [".vbs", “.exe”, “.h”]
irb(main):008:0> b.include?(".rb")
=> false
irb(main):009:0> [".vbs",".exe",".h"].include?(".rb")
=> false
irb(main):010:0> [1,2,3].inculde?(1)
NoMethodError: undefined method inculde?' for [1, 2, 3]:Array from (irb):10 from C:/Ruby193/bin/irb:12:in
irb(main):011:0>

Could you please if is it possible what I am looking for or I did the
mistake?

Thanks

On 01/31/2013 11:01 PM, Arup R. wrote:

=> false
irb(main):010:0> [1,2,3].inculde?(1)
NoMethodError: undefined method inculde?' for [1, 2, 3]:Array from (irb):10 from C:/Ruby193/bin/irb:12:in
irb(main):011:0>

Could you please if is it possible what I am looking for or I did the
mistake?

Thanks

You are misspelling “include” :slight_smile:

-Justin

`inculde?’ -> check the spell
it should be include?

Am 01.02.2013 08:01, schrieb Arup R.:

I was trying to write a one liner with integer array using
array#include?,which is not working.But the same is good with
character/string array.

The error messages are telling you what the problem is (typos).

On 01/31/2013 11:27 PM, Arup R. wrote:

mistake?

@extension = File.extname(link_text)
driver.find_element(:link, link_text).click if
[".pdf",".gif",".bmg",“tif”,".tiff",“jpeg”,".jpg"].include?(@extension)

Without knowing anything about what “driver” is, I would say yes.

-Justin

Justin C. wrote in post #1094691:

On 01/31/2013 11:01 PM, Arup R. wrote:

=> false
irb(main):010:0> [1,2,3].inculde?(1)
NoMethodError: undefined method inculde?' for [1, 2, 3]:Array from (irb):10 from C:/Ruby193/bin/irb:12:in
irb(main):011:0>

Could you please if is it possible what I am looking for or I did the
mistake?

Thanks

You are misspelling “include” :slight_smile:

-Justin

The below should work right Logically ?

@extension = File.extname(link_text)
driver.find_element(:link, link_text).click if
[".pdf",".gif",".bmp",“tif”,".tiff",“jpeg”,".jpg"].include?(@extension)

Am 01.02.2013 08:27, schrieb Arup R.:

mistake?

@extension = File.extname(link_text)
driver.find_element(:link, link_text).click if
[".pdf",".gif",".bmg",“tif”,".tiff",“jpeg”,".jpg"].include?(@extension)

A friendly meant suggestion: Instead of writing posts like this
and the previous one you could spend your (and our) time better
with attentively reading the error messages, re-reading your code
carefully and simply trying whether it works on simple examples.

This applies here also:

ext = ‘gif’
puts ‘an image!’ if [".gif", “tif”, ‘.jpg’].include?(ext)

no output

ext = ‘tif’
puts ‘an image!’ if [".gif", “tif”, ‘.jpg’].include?(ext)

“an image”

You have to ask yourself:
is the dot supposed to be included in your @extension string or not?