This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html Set by lizmat on 8 June 2022. |
|||
aruniecrisps | now i'm getting a $*RED-DB wasn't defined in the application, but it seems like i would have to define it in lib/Routes.rakumod? | 00:34 | |
SmokeMachine | Yes, currently the best way of doing that is with `red-defaults` | 00:35 | |
aruniecrisps | got it | 00:36 | |
SmokeMachine | Let me know if that’s working | 00:37 | |
aruniecrisps | Yep it works | 00:38 | |
SmokeMachine | \o/ | ||
Are you going to use sessions with Red? | 00:41 | ||
If so, maybe something like this would help: github.com/FCO/Cro-HTTP-Session-Red | 00:46 | ||
aruniecrisps | Very likely | 00:49 | |
@SmokeMachine i'm running into this issue where i try and do .new on a model Post, and then later do .^save, but it's giving me this error: Cannot look up attributes in a Post type object. Did you forget a '.new'? | 00:51 | ||
SmokeMachine | It seems it’s not being initialised… can I see the code? | 00:52 | |
aruniecrisps | sub post-routes() { route { get -> { my @posts = Post.^all; template 'all-posts.crotmp', { :@posts }; } get -> 'new' { template 'new-post.crotmp'; } post -> { request-body -> (:$title, :$body) { my Post $post = Post.new(:$title, :$body); say "Post title: $title"; say "Post body: | ||
$body"; Post.^save; } } } } | |||
SmokeMachine | Would you mind to share it as a snippet or repo? | 00:53 | |
aruniecrisps | i just pushed changes up | 00:54 | |
SmokeMachine | What file are you doing that? | 00:59 | |
Sorry, I found it | 01:01 | ||
You are saving the model instead of the instantiated object | 01:02 | ||
01:02
swaggboi joined
|
|||
SmokeMachine | You should do `$post.^save` | 01:03 | |
aruniecrisps | I'M AN IDIOT | ||
01:04
swaggboi left
|
|||
SmokeMachine | Working? | 01:07 | |
aruniecrisps | yep | 01:09 | |
it works | |||
SmokeMachine | \o/ | ||
01:53
swaggboi joined
03:07
Jit joined
03:08
Jit left
08:58
dakkar joined
11:31
CIAvash joined
11:49
CIAvash left
11:50
CIAvash joined
12:53
CIAvash left
13:41
tbrowder__ left
13:45
tbrowder__ joined
13:52
ab5tract left
13:54
ab5tract joined,
tbrowder__ left
13:59
SmokeMachine left,
ab5tract left
14:03
tbrowder__ joined
14:04
ab5tract joined
14:12
tbrowder__ left
14:16
tbrowder__ joined
14:22
tbrowder__ left
14:23
tonyo left
14:25
tonyo joined
|
|||
doodler8888 | I'm completely new to Raku and working on a simple script to add or remove the ".bak" extension from a file. I'd like to use a flag (like "-c") to switch between using the move and copy functions. I want to achieve this with two separate subroutines for clarity. Here's what I have so far, but I'm running into an issue with how the subroutines are selected if I don't provide a flag: multi MAIN($filename, Bool :$m = False) { | 14:25 | |
if $filename ~~ / .bak$ / { my $new_filename = $filename.subst(/.bak$/, ''); move($filename, $new_filename); } else { my $new_filename = "$filename.bak"; move($filename, $new_filename); } } multi MAIN($filename, Bool :$c = False) { if $filename ~~ / .bak$/ { my $new_filename = $filename.subst(/.bak$/, ''); copy($filename, $new_filename); } else { my | |||
$new_filename = "$filename.bak"; copy($filename, $new_filename); I've noticed some odd behavior when trying to select between my two subroutines. Without any flag present, the second subroutine (the one intended for the '-c' flag) always runs, even though I want the first to be the default. I was able to work around this by adding a placeholder "-m" flag to the first subroutine, which feels like a hack. I could also add an if $c | |||
check to the second subroutine, but I suspect there's a more elegant Raku way to handle default subroutine selection that I'm missing. | |||
14:36
tbrowder__ joined
14:37
SmokeMachine joined
|
|||
MasterDuke | doodler8888: do you know about the `is default` trait for multis? | 15:22 | |
15:48
ab5tract left,
ab5tract joined
|
|||
doodler8888 | like this? multi sub MAIN($filename) is default { if $filename ~~ / \.bak$ / { my $new_filename = $filename.subst(/\.bak$/, ''); move($filename, $new_filename); } else { my $new_filename = "$filename.bak"; move($filename, $new_filename); } } multi sub MAIN($filename, Bool :$c = False) { if $filename ~~ / \.bak$/ { my $new_filename = $filename.subst(/\.bak$/, | 16:00 | |
''); copy($filename, $new_filename); } else { my $new_filename = "$filename.bak"; copy($filename, $new_filename); } } raku still executes the second subroutine if no flag is provided. i also tried to use 'where': multi sub MAIN($filename where Bool :$c) { | |||
SmokeMachine | m: multi sub MAIN($filename) { say "first" }; multi sub MAIN($filename, Bool :$c!) { say "second" }; @*ARGS.append: "bla" | 16:23 | |
camelia | first | ||
SmokeMachine | m: multi sub MAIN($filename) { say "first" }; multi sub MAIN($filename, Bool :$c!) { say "second" }; @*ARGS.append: "-c", "bla" | 16:24 | |
camelia | second | ||
SmokeMachine | doodler8888: ☝️ | ||
Nahita | > Without any flag present, the second subroutine (the one intended for the '-c' flag) always runs, even though I want the first to be the default I cannot reproduce that; always the firstly defined one wins for me, and documentation also talks it that way | 16:27 | |
SmokeMachine | the 2nd one does not require the flag (named parameters are optional (`?`) unless you add a `! `) | 16:29 | |
doodler8888 | much obliged | 17:00 | |
17:09
tbrowder__ left
17:13
tbrowder__ joined
17:33
dakkar left
|
|||
lizmat | And yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2024/02/19/2024-...completed/ | 18:08 | |
holmdunc | lizmat: Your submissions to HN are being blocked for some reason (11 of the last 20 marked [dead]). If you email the moderator via the Contact link, he will probably sort it out for you | 21:11 | |
antononcube | HN == Hacker News ? | 21:33 | |
Not say "Hungry Ninjas" or "Hilarious Nonsense"... | 21:35 | ||
gfldex | @antononcube Now I want that site be called "Hilarious Nonsense". :-> | 21:38 | |
vendethiel | It’s its informal name | 21:59 | |
antononcube | Let us ask ChatGPT: > openai-playground --max-tokens=300 say 10 funny interpretations of the abbreviation HN | 22:06 | |
1. Hot Noodles 2. Hairy Nipples 3. Hipster Nachos 4. Happy Narwhals 5. Horny Nerds 6. Hungry Ninjas 7. High Noon 8. Hilarious Nincompoops 9. Heavenly Nachos 10. Happy Nurses | |||
lizmat | holmdunc typical, I guess I'll strike HN from my list to post things | 23:00 | |
I've had experiences with moderators before: they seem to think what I post is by definition not worthy of HN | 23:01 | ||
23:02
hudo__ left,
hudo__ joined
|
|||
lizmat | oddly enough my posts *are* visible in the search engine | 23:03 |