<div dir="auto">I have nothing useful to add other than saying that, yes, you are in the right spot, and I also think this feature is a really good idea.<div dir="auto"><br></div><div dir="auto">That said, having it return the object in question means that tracing down your print statements so that you can delete them will be a little harder. Not a good enough reason to say no, mind you, but something to keep in mind.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Feb 18, 2024, 1:00 PM <<a href="mailto:dennis_woithe@web.de">dennis_woithe@web.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:Verdana;font-size:12.0px"><div>
<div>Hello,</div>
<div>I hope this email finds you well.</div>
<div>I have recently reviewed the draft for the JEP "Implicitly Declared Classes and Instance Main Methods (Third Preview)" and came up with a suggestion for a minor enhancement to the SimpleIO class.</div>
<div>The JEP aims to enhance the accessibility of simple IO actions, primarily by introducing the SimpleIO class to the <a href="http://java.io" target="_blank" rel="noreferrer">java.io</a> package with the following signatures:</div>
<div><br>
<span style="font-family:Courier New,Courier,monospace">public class SimpleIO {<br>
public static void println(Object obj) ...<br>
public static void print(Object obj) ...<br>
public static String input(String prompt) throws UncheckedIOException ...<br>
}</span></div>
<div> </div>
<div>One of the proposed functionalities is to allow implicitly declared classes to automatically import the static methods of SimpleIO, thereby simplifying console input and output operations for beginner programmers.</div>
<div>I propose a small addition to the SimpleIO class that would enhance its usability further. Specifically, I suggest modifying the println and print methods to return the passed object, enabling the inlining of print(ln) statements. Here's the proposed modification:</div>
<div> </div>
<div><br>
<span style="font-family:Courier New,Courier,monospace">public static <T> T println(T obj) {<br>
System.out.println(obj);<br>
return obj;<br>
}<br>
public static <T> T print(T obj) {<br>
System.out.print(obj);<br>
return obj;<br>
}</span></div>
<div> </div>
<div>This enhancement would facilitate constructs such as:</div>
<div><br>
<span style="font-family:Courier New,Courier,monospace">return foo<br>
? println(bar())<br>
: baz();</span></div>
<div> </div>
<div>This change would particularly benefit beginners who wish to quickly print something without first creating a variable for it. Additionally, users exploring the SimpleIO class would have a very basic exposure to generic methods.</div>
<div>I believe this suggestion aligns with the objectives of the JEP and would enhance the user experience for novice programmers.</div>
<div>Please let me know if this email is the appropriate channel for submitting such suggestions. If not, I would appreciate guidance on the correct procedure.</div>
<div>Thank you for considering my proposal.<br>
</div>
<div>Best regards,</div>
<div>Dennis Woithe</div>
</div></div></div>
</blockquote></div>