printf can not print an integer

Remi Forax forax at univ-mlv.fr
Sun Apr 26 07:01:35 UTC 2015


On 04/26/2015 12:50 AM, Robert Field wrote:
> Right, we could also have a shortcut for print (as opposed to printf):
>
>      void print(Object arg) { System.out.print(arg); }
>
> Yes?
>
> -Robert

yes :)

here is my startup script, btw:

import java.util.*;
import java.io.*;
import java.nio.file.*;
import java.math.*;
import java.util.function.*;
import java.util.stream.*;
import java.util.regex.*;
void printf(String format, Object... args) { System.out.printf(format, 
args); }
void print(Object value) { System.out.println(value); }

I've added imports * of java.util.function, java.util.stream and 
java.nio.file
so one can write things like this:

-> Consumer<Object> printer = System.out::println;
|  Modified variable printer of type Consumer<Object> with initial value 
$Lambda$8/1419810764 at 36f6e879

-> Files.list(Paths.get(".")).forEach(printer);

cheers,
Rémi

>
> On 04/23/15 07:21, Remi Forax wrote:
>> Ok, I see.
>> perhaps a simple Python style 'print' should be added in that case ?
>>
>> regards,
>> Rémi
>>
>> On 04/23/2015 04:17 PM, andrei.eremeev wrote:
>>> In REPL, printf is not a C-style printf. REPL's printf has 
>>> parameters: String a, Object...b, where 'a' is a template.
>>>
>>> Andrei
>>>
>>> On 04/23/2015 05:11 PM, Remi Forax wrote:
>>>> 'printf' should be a method that takes an Object as parameter and 
>>>> not a String.
>>>>
>>>> -> printf(2)
>>>> |  Error:
>>>> |  incompatible types: int cannot be converted to java.lang.String
>>>> |  printf(2)
>>>> |         ^
>>>>
>>>> cheers,
>>>> Rémi
>>>>
>>>>
>>>
>>
>



More information about the kulla-dev mailing list