Fahad/CodeSamples/GenericClasses.scala
changeset 44 a751aa1ee4f7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Fahad/CodeSamples/GenericClasses.scala	Sun Nov 09 19:25:10 2014 +0000
@@ -0,0 +1,17 @@
+package Main
+
+class Stack[T] {
+  var elems: List[T] = Nil
+  def push(x: T) { elems = x :: elems }
+  def top: T = elems.head
+  def pop() { elems = elems.tail }
+}
+
+object GenericsTest extends App{
+  val stack = new Stack[Int]
+  stack.push(1)
+  stack.push('a')
+  println(stack.top)
+  stack.pop()
+  println(stack.top)
+}
\ No newline at end of file