# Question on watir

**URL:** <https://www.ruby-forum.com/t/question-on-watir/224437>\
**Category:** Ruby\
**Created:** [November 12, 2012, 5:45am UTC](https://www.ruby-forum.com/t/question-on-watir/224437 "2012-11-12T05:45:39Z")\
**Posts on this page:** 15\
**Page:** 12

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 12, 2013, 1:01pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/221 "2013-04-12T13:01:05Z")

</div>

hi,

do we have anything equivalent to static keyword in C? My motto is value  
has to be preserved even after the function return, Global variable is  
one of the way to do this, But I guess something equivalent to static  
keyword would be a better solution.

RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 12, 2013, 8:27am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/222 "2013-04-12T08:27:34Z")

</div>

when i try to print the elements as you have explained, it throws the  
same error,

`each_element': undefined method`each’ for nil:NilClass (NoMethodError)

I am trying for Gmail username and password, So can you try to with  
Gmail and tell me whether it’s working for you or not?

RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 12, 2013, 3:46pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/223 "2013-04-12T15:46:40Z")

</div>

Am 12.04.2013 08:27, schrieb Raj pal:

> when i try to print the elements as you have explained, it throws the  
> same error,
> 
> `each_element': undefined method `each’ for nil:NilClass (NoMethodError)

That’s strange because in my example `each` has not been called  
at all…

Anyway: What the error message is trying to convey to you is  
that you are trying to call `each` for an object that is nil:

$ irb  
1.9.3p392 :001 \> a = nil  
=\> nil  
1.9.3p392 :002 \> a.each {|element| puts element }  
NoMethodError: undefined method `each’ for nil:NilClass

So, `$browser.elements` seems to be nil for some reason.

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 12, 2013, 3:47pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/224 "2013-04-12T15:47:51Z")

</div>

Am 12.04.2013 13:01, schrieb Raj pal:

> hi,
> 
> do we have anything equivalent to static keyword in C?
> 
> RAJ

Please start a new thread for unrelated questions.

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 16, 2013, 1:26pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/225 "2013-04-16T13:26:54Z")

</div>

$ irb  
1.9.3p392 :001 \> a = nil  
=\> nil  
1.9.3p392 :002 \> a.each {|element| puts element }  
NoMethodError: undefined method `each’ for nil:NilClass

So, `$browser.elements` seems to be nil for some reason.

OK

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 17, 2013, 11:51am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/226 "2013-04-17T11:51:04Z")

</div>

can you tell me what is the difference between  
a=[2,3,3,5]  
a=Hash[\*b]# It’s converting into hash  
a=Hash[b]#it’s converting if a consist of any array

What is the job of “\*” here?

And also I would like to know what is the difference does it make for

def hi(\*h)  
end  
def hi(h)  
end

RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 17, 2013, 1:08pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/227 "2013-04-17T13:08:55Z")

</div>

- here converts an array to a list of arguments.

so,

in:

args\_ary = [1,2]  
hash = Hash[\*args\_ary]

it’s the same as

hash = Hash[1,2]

where as  
args\_ary = [1,2]  
hash = Hash[args\_ary]

is the same as

hash=Hash[[1,2]]

… which will give you a bunch of warnings and just set hash to an  
empty Hash.

J

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 17, 2013, 1:48pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/228 "2013-04-17T13:48:23Z")

</div>

The word you’re looking for is “splat”. I found this link quite useful  
when I discovered them:

> **[The Strange Ruby Splat](https://endofline.wordpress.com/2011/01/21/the-strange-ruby-splat/)**
>
> This article has been republished on Monkey and Crow. As of ruby 1.9, you can do some pretty odd things with array destructuring and splatting. Putting the star before an object invokes the splat o…

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 24, 2013, 7:33am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/229 "2013-04-24T07:33:28Z")

</div>

hi,

Class.class==Class

Every class we create is an object of a class Class, but how can Class  
itself object of it’s own? Can we create such a class?

RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 24, 2013, 10:15am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/230 "2013-04-24T10:15:26Z")

</div>

Class is part of Ruby’s core. Any class you make will be an instance of  
Class. As far as I know you could modify class Class but not overwrite  
it, although I’d consider that rather dangerous since virtually  
everything inherits from Class.

This might help you understand it:

> <https://stackoverflow.com/questions/1219691/why-object-class-class-in-ruby>

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 18, 2013, 8:26am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/231 "2013-04-18T08:26:42Z")

</div>

hi Julian L.

Thank you .I understood what you meant.

hi Joel P.

Yes this is what I expected.thank you.

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 24, 2013, 11:19am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/232 "2013-04-24T11:19:45Z")

</div>

Because the implementation is written in C, not Ruby. Ruby works through  
an interpreter, and the circular reference there is part of the  
framework that the language works through. I don’t think it’s something  
you can replicate from within Ruby, only by writing your own  
interpreter. Why would you need to, anyway?

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 24, 2013, 11:29am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/233 "2013-04-24T11:29:41Z")

</div>

Not for my work, Just to know how that is possible. Because i haven’t  
seen such an implemention so far.

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 24, 2013, 10:59am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/234 "2013-04-24T10:59:58Z")

</div>

Yep this is ok, this i understood. My main focus is, how can Class be  
instance of it’s own? Class.class=Class.  
Can we able to create a class like that? Instance is only possible after  
declaration of class, But here Class is an instance of Class as well.  
How it’s possible?

RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [April 24, 2013, 12:59pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/235 "2013-04-24T12:59:26Z")

</div>

I understood what you meant.

[Previous page](https://www.ruby-forum.com/t/question-on-watir/224437.md?page=11)
