From b591de609b576d0960ca7ecb234565007cedbb1f Mon Sep 17 00:00:00 2001 From: qorg11 Date: Thu, 9 Dec 2021 19:58:36 +0100 Subject: [PATCH] Fixed raku example --- rocks/computers/software/langs/raku.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rocks/computers/software/langs/raku.md b/rocks/computers/software/langs/raku.md index 5285e18..e80853e 100644 --- a/rocks/computers/software/langs/raku.md +++ b/rocks/computers/software/langs/raku.md @@ -48,18 +48,18 @@ Class Socket { has Int $.sockfd; method new ($path) { - my $mfd = create_socket(); - connect_socket($mfd,$path); - self.bless(sockfd => $mfd); + my $mfd = create_socket(); # This is a function written in C called with NativeCall + connect_socket($mfd,$path); # Idem + self.bless(sockfd => $mfd); # Give the attributes to the object } method send($str) { my $len = $str.chars; - write_to_sock(self.sockfd, $str, $len); + write_to_sock(self.sockfd, $str, $len); # C func } } my $sock = Socket.new("path/to/socket"); -$sock.write("hello from raku!"); +$sock.send("hello from raku!"); Calling C functions from Raku is stupidly easy, to do this only use