Confusion with attr_accessor

I have two question regarding ruby programming if someone can help me
with that,I am looking for the syntax as i am confused with these
questions.

  1. Define a method attr_accessor_with_history that provides the same
    functionality as attr_accessor but also tracks every value the attribute
    has ever had.

  2. the Enumerable module includes an iterator each_with_index that
    yields each enumerable element along with an index starting from
    zero(recall that Enumerable is mixed into Ruby’s built in collection
    classes by default)

On Thu, Feb 6, 2014 at 3:13 PM, Mish A. [email protected] wrote:

yields each enumerable element along with an index starting from
zero(recall that Enumerable is mixed into Ruby’s built in collection
classes by default)

Actually, no - you have an imperative statement and an ostensibly
factual statement. Would you like to ask questions about those? If
so, what are they exactly?

for the first q

class foo
attr_accessor_with_history :bar
end

I need when I compile it its gives me

f=Foo.new #=> #Foo:0x127e678
f.bar =3 #=> 3
f.bar = :wowzo #=> :wowzo
f.bar = ‘boo!’ #=> ‘boo!’
f.history(:bar) #=> [3, :wowzo, ‘boo!’]

On Thu, Feb 6, 2014 at 5:10 PM, Mish A. [email protected] wrote:

I need when I compile it its gives me

f=Foo.new #=> #Foo:0x127e678
f.bar =3 #=> 3
f.bar = :wowzo #=> :wowzo
f.bar = ‘boo!’ #=> ‘boo!’
f.history(:bar) #=> [3, :wowzo, ‘boo!’]

That description is close to being a usable test, but I still don’t see
any question :slight_smile:

Hassan S. wrote in post #1135882:

On Thu, Feb 6, 2014 at 3:13 PM, Mish A. [email protected] wrote:

yields each enumerable element along with an index starting from
zero(recall that Enumerable is mixed into Ruby’s built in collection
classes by default)

Actually, no - you have an imperative statement and an ostensibly
factual statement. Would you like to ask questions about those? If
so, what are they exactly?

for the first q

class foo
attr_accessor_with_history :bar
end

I need when I compile it its gives me

f=Foo.new #=> #Foo:0x127e678
f.bar =3 #=> 3
f.bar = :wowzo #=> :wowzo
f.bar = ‘boo!’ #=> ‘boo!’
f.history(:bar) #=> [3, :wowzo, ‘boo!’]

On Feb 7, 2014, at 3:37 AM, Hassan S.
[email protected] wrote:

That description is close to being a usable test, but I still don’t see
any question :slight_smile:

It smells like the question is: Will you do my homework for me?

Ammar A. wrote in post #1135904:

On Feb 7, 2014, at 3:37 AM, Hassan S.
[email protected] wrote:

That description is close to being a usable test, but I still don’t see
any question :slight_smile:

It smells like the question is: Will you do my homework for me?

Yes they r homework qs i dont know hw to do them
Iam new in ruby so i need a help
Nothing more

On Thu, Feb 6, 2014 at 7:37 PM, Mish A. [email protected] wrote:

Yes they r homework qs i dont know hw to do them

So what have you tried so far?

On Fri, Feb 7, 2014 at 4:37 AM, Mish A. [email protected] wrote:

Iam new in ruby so i need a help
Nothing more

People in this list are usually reluctant to just hand out solutions
for homework, specially if the person asking the question doesn’t show
some effort in trying to solve the problem by themselves. If you had
done some effort and be blocked by something you didn’t understand,
you would probably ask a very different question than the one you’ve
asked and you would get better answers.

Just to point you in the right direction if you are really lost: look
around the internet for a ruby implementation of attr_accessor (there
are a lot of examples of how you would go about implementing it), and
then modify that implementation so that you store the previous value
in an array.

If you have any problem just show us what you’ve done, and what’s
blocking you and we will try to help.

Jesus.

On Thu, Feb 6, 2014 at 10:23 PM, Ammar A. [email protected]
wrote:

It smells like the question is: Will you do my homework for me?

Maybe someone should set up http://willyoudomyhomeworkforme.com/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs