Could you do
return Area(Float (Left) * Float (Right));
Re:Ada for the C++ and Java Developer [pdf]
by bob-ROS on Sunday March 28, 2021 @08:23AM
(#26609738)
Yes, that works.
Re:Ada for the C++ and Java Developer [pdf]
by webreac on Sunday March 28, 2021 @04:29PM
(#26614179)
Could you do
return Area (Distance (Left * Right));
?
Re:Ada for the C++ and Java Developer [pdf]
by OneWingedShark on Tuesday March 30, 2021 @09:33AM
(#26634413)
IIRC, the one-liner here [assuming you disabled the default "" operator] would be:
Return Area( Distance'Base'(Left * Right) );
The apostrophe at the inner portion is 'qualification', a method for directing the compiler that the enclosed value is supposed to be a particular subtype. (Typically used to resolve ambiguities.)
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
Interestingly, it took me several attempts to create this overload, make it a single line return would make it recursive: Also: