When I run this code
require Readline;
my $rl = Readline.new;
my $string = $rl.readline( ':');
$string.say;
I get this error-message:
You cannot create an instance of this type (Readline)
When I use use
to load Readline
it works. Why does require Readline
not work?
Since require
causes the module to be loaded at runtime, the lookup of the Readline
symbol must also be deferred until runtime. This can be done using the ::('Type::Name')
syntax, as follows:
require Readline;
my $rl = ::('Readline').new;
my $string = $rl.readline( ':');
$string.say;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With