Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Ruby Array Stack Class

Posted on 2010-11-27
3
Medium Priority
?
1,036 Views
Last Modified: 2012-05-10

my assignment is to implement a stack class (based on Array) using push, pop, length and empty.

Also, to provide example test code which makes use of the stack.  
Have I satisfied this?  At line 21 would be the example code?  or is this part of my stack?

Thanks for looking, my professor expects us to pick up Ruby in one week and won't answer questions over the Holiday.
0
Comment
Question by:aflamin2424
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
JESii earned 1000 total points
ID: 34223894
Seems to work fine for me; yes, line 21 on is your test code.

It's always a good thing to test some of the boundary conditions, like what happens when you try to pop from an empty stack... I added this to your test code at the end, when the stack was empty.

If you can think of other error or boundary conditions, you can add those to your test suite as well.


test = stack.pop
puts "Result from empty stack: " +( test.nil? ? "nil" : test)
puts stack.length

Open in new window

0
 

Author Closing Comment

by:aflamin2424
ID: 34227731
Thank you
0
 
LVL 12

Expert Comment

by:JESii
ID: 34227922
You're welcome; thanks for the points!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question