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.
Amit A. (Guest)
on 2009-01-02 13:38
Hi,
Is there any function to flush the value from a variable. I am facing
problem while assiging a value to Ruby variable.
Andrew T. (Guest)
on 2009-01-02 13:44
(Received via mailing list)
On Fri, Jan 2, 2009 at 1:37 PM, Amit A. <removed_email_address@domain.invalid>
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
Amit A. (Guest)
on 2009-01-02 13: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 T. wrote:
> On Fri, Jan 2, 2009 at 1:37 PM, Amit A. <removed_email_address@domain.invalid>
> 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
Andrew T. (Guest)
on 2009-01-02 14:04
(Received via mailing list)
On Fri, Jan 2, 2009 at 1:49 PM, Amit A. <removed_email_address@domain.invalid>
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 T.
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

"I have never let my schooling interfere with my education" - Mark Twain
Sebastian H. (Guest)
on 2009-01-02 14:11
(Received via mailing list)
Amit A. 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
Michael L. (Guest)
on 2009-01-02 16:08
(Received via mailing list)
>> Andrew T. 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.