Forum: Ruby Function to flush the variable

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
153b0cec3192a686b46c8a7cba253c6d?d=identicon&s=25 Amit Agarwal (amitjhs)
on 2009-01-02 12:38
Hi,
Is there any function to flush the value from a variable. I am facing
problem while assiging a value to Ruby variable.
5772c599ccab3081e0fffb1d54f3b6de?d=identicon&s=25 Andrew Timberlake (andrewtimberlake)
on 2009-01-02 12:44
(Received via mailing list)
On Fri, Jan 2, 2009 at 1:37 PM, Amit Agarwal <amitjhs2000@gmail.com>
wrote:

> Hi,
> Is there any function to flush the value from a variable. I am facing
> problem while assiging a value to Ruby variable.
> --
> Posted via http://www.ruby-forum.com/.
>
>
What do you mean by flush? Remove the current value?
  my_var = nil
should do that
153b0cec3192a686b46c8a7cba253c6d?d=identicon&s=25 Amit Agarwal (amitjhs)
on 2009-01-02 12:50
I am trying to use following code

Status=sheet1.getCellByPosition(5, I).Formula
ie.text_field(:name, "FieldName").value =Status


and it works fine, but On itetrating this piece of code for multiple I/
Ps, variable 'name', retains its old value for some of the cases. I
identified this as a cache problem. Please suggest if there any flush
() type function or action in Ruby/watir to clear the garbage value.

actually there is function in C, i.e. flush which clears the garbage
value.


Andrew Timberlake wrote:
> On Fri, Jan 2, 2009 at 1:37 PM, Amit Agarwal <amitjhs2000@gmail.com>
> wrote:
>
>> Hi,
>> Is there any function to flush the value from a variable. I am facing
>> problem while assiging a value to Ruby variable.
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>>
> What do you mean by flush? Remove the current value?
>   my_var = nil
> should do that
5772c599ccab3081e0fffb1d54f3b6de?d=identicon&s=25 Andrew Timberlake (andrewtimberlake)
on 2009-01-02 13:04
(Received via mailing list)
On Fri, Jan 2, 2009 at 1:49 PM, Amit Agarwal <amitjhs2000@gmail.com>
wrote:

>
> >> problem while assiging a value to Ruby variable.
>
>
A 'variable' with an uppercase first letter is actually a constant in
ruby
and you can only assign to it once.
Change 'Status' to 'status' and you should see it work

--
Andrew Timberlake
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

"I have never let my schooling interfere with my education" - Mark Twain
7a561ec0875fcbbe3066ea8fe288ec77?d=identicon&s=25 Sebastian Hungerecker (Guest)
on 2009-01-02 13:11
(Received via mailing list)
Amit Agarwal wrote:
> actually there is function in C, i.e. flush which clears the garbage
> value.

In ruby there is a method IO#flush which flushes an output stream the
same way
flush in C does. This has nothing to do with variables, however.

HTH,
Sebastian
26a81e5badb9e002ab9ed3542036e584?d=identicon&s=25 Michael Libby (Guest)
on 2009-01-02 15:08
(Received via mailing list)
>> Andrew Timberlake wrote:

> A 'variable' with an uppercase first letter is actually a constant in ruby
> and you can only assign to it once.
> Change 'Status' to 'status' and you should see it work

In Ruby you can assign to a constant as many times as you like. You
will be scolded for it, but it's allowed.

irb(main):001:0> IMA_CONST = "foo"
=> "foo"
irb(main):002:0> IMA_CONST = "bar"
(irb):2: warning: already initialized constant IMA_CONST
=> "bar"
irb(main):003:0> IMA_CONST = "baz"
(irb):3: warning: already initialized constant IMA_CONST
=> "baz"
irb(main):004:0> IMA_CONST
=> "baz"

-Michael
This topic is locked and can not be replied to.