Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-dev] Re: idea for refactoring

Nope :)
varargs  are also useful.
But sometimes like Dan said you have something like this:

public void printSomeStuff(String s)
{
   printSomeStuff(String s, "default prefix: ");
}

public void printSomeStuff(String s, String prefix)
{
   System.out.println(prefix + " -->  " + s);
}


It would be nice to have just:

public void printSomeStuff(String s, String prefix = "default prefix: ")
{
   System.out.println(prefix + " -->  " + s);
}



Maybe not a very nice example, but it shows what Dan and I mean.
Dan wants to have the following (tell me if I'm wrong here somewhere, Dan):
Refactor: Create optional arguments methods (Can't think of a name)

This will popup a dialog with the selected method and parameters:

==============================
main method: printSomeStuff(String s, String prefix)

optional   parameter    default value
[ ]            s
[x]            prefix          ["default prefix: "]


                             OK
==============================


This, and another refactoring that will let you change all calls to the method with default parameters (everywhere that calls: printSomeStuff(xxxx, "default prefix: ") into the short call (printSomeStuff(xxxx))

I hope this was clear, and that the dialog shows properly..

-Joris


Gregg G. Wonderly wrote:

I think I was a bit unclear un this. It's not in de 1.5/5 spec, but it would be one of those things that would be nice to have.

Humm, the printf formatting feature uses variable length argument lists. Is this what you are looking for?

-----
gregg@xxxxxxxxxxxx  (Cyte Technologies Inc)


_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/jdt-dev





Back to the top