2 ms·
Not being able to directly print an integer without calling a function to convert it to a string is awkward. The article presents this bit of code: with ada
by Bostonian 5y ago
Not being able to directly print an integer without calling a function to convert it to a string is awkward. The article presents this bit of code:
with ada.Text_IO;
use Ada.Text_IO;
procedure Main is
myNumber: Integer;
begin
myNumber := 123;
Put_Line ( Integer'Image (myNumber) );
end Main;
- synack 5y agoThere are several ways to do this. Put_Line (myNumber'Image); works just as well as Integer'Image. with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; Put (myNumber); Integer_Text_IO is included in the standard library. More info here: http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-A-10-8.html http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-A-10-8.... There's also a proposal to add format strings to the language: https://github.com/AdaCore/ada-spark-rfcs/pull/77 https://github.com/AdaCore/ada-spark-rfcs/pull/77
- deleted 5y ago[deleted]