The Artima Developer Community
Sponsored Link

Java Buzz Forum
Aren't You Happy Java Don't Have Default Arguments

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Weiqi Gao

Posts: 1808
Nickname: weiqigao
Registered: Jun, 2003

Weiqi Gao is a Java programmer.
Aren't You Happy Java Don't Have Default Arguments Posted: Sep 13, 2005 6:55 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Weiqi Gao.
Original Post: Aren't You Happy Java Don't Have Default Arguments
Feed Title: Weiqi Gao's Weblog
Feed URL: http://www.weiqigao.com/blog/rss.xml
Feed Description: Sharing My Experience...
Latest Java Buzz Posts
Latest Java Buzz Posts by Weiqi Gao
Latest Posts From Weiqi Gao's Weblog

Advertisement

Trond Andersen: I talked with someone looking at Ruby to use for a prototype and didn't want Java's verbose syntax and complex APIs. I suggested Python as a good alternative since it got better support for GTK than Ruby and RedHat and others uses the language alot, but it seemed like they had rejected Python as an alternative for such a relative large prototype. I just had to ask why. So he fired up the console on his Mac and typed:

...

Try it !!!! It wasn't quite what I've expected.

Go figure.....

Here's what I got when I tried:

[weiqi@gao] $ python
Python 2.3.4 (#1, Feb  2 2005, 12:11:53)
[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> class foo:
...   def __init__(self, x=[]):
...     self.y = x
... 
>>> a = foo()
>>> a.y.append("123456")
>>> a.y
['123456']
>>> b = foo()
>>> b.y
['123456']
>>> a.y.append("98765")
>>> a.y
['123456', '98765']
>>> b.y
['123456', '98765']

The explanation is here.

Read: Aren't You Happy Java Don't Have Default Arguments

Topic: The new JBoss Installer Previous Topic   Next Topic Topic: Seth Godin’s Knock Knock online marketing book now available

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use