Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

DuckTyping

Name: Anonymous 2010-07-03 4:45

namespace DuckTyping
{
  using System;
 
  public class Duck
  {
    public void Quack()
    {
      Console.WriteLine("Quaaaaaack!");
    }
 
    public void Feathers()
    {
      Console.WriteLine("The duck has white and gray feathers.");
    }
  }
 
  public class Person
  {
    public void Quack()
    {
      Console.WriteLine("The person imitates a duck.");
    }
 
    public void Feathers()
    {
      Console.WriteLine("The person takes a feather from the ground and shows it.");
    }
  }
 
  internal class Program
  {
    private static void InTheForest(dynamic duck)
    {
      duck.Quack();
      duck.Feathers();
    }
 
    private static void Game()
    {
      dynamic duck = new Duck();
      dynamic person = new Person();
      InTheForest(duck);
      InTheForest(person);
    }
 
    private static void Main()
    {
      Game();
    }
  }
}

Name: Anonymous 2010-07-03 4:51

Cool story.

Name: Anonymous 2010-07-03 4:53

[code].

Name: Anonymous 2010-07-03 6:17

They should change the term "duck typing" to something more suitable. Programmers already have a hard enough time with strong/weak/static/dynamic typing without overloading their heads with something completely unrelated to the type system.

Name: Anonymous 2010-07-03 6:33

Ducks are Touring-complete.

Name: Anonymous 2010-07-03 6:51

Congratulations on copying the Wikipedia article verbatim.

Name: Anonymous 2010-07-03 8:09

I'ma ducktyping with mah Python!

Name: Anonymous 2010-07-03 8:17

Stop posting, faggiotto.

Name: Anonymous 2010-07-03 22:50

>>4
At least it's not ``monkey patching''.

Name: Anonymous 2011-02-03 3:39

Don't change these.
Name: Email:
Entire Thread Thread List