Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ This project features a variety of implementations in many programming languages
- [Vala](/Vala.vala)
- [VBScript](/VBScript.vbs)
- [VisualBasic](/VisualBasic.vb)
- [Vlang](/vlang.v)
- [Wolfram](/Wolfram.wl)
- [Xamarin](/Xamarin.xaml)
- [Zig](/Zig.zig)
Expand Down
7 changes: 7 additions & 0 deletions vlang.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import readline

fn main() {
mut r := readline.Readline{}
answer := r.read_line('Ask me something: ')!
println('Sorry, I can\'t help you with this. $answer')
Comment on lines +5 to +6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Using the '!' operator will panic on error; consider handling input errors gracefully.

Explicit error handling here would improve user experience by avoiding unexpected panics and allowing for a more informative response to input errors.

Suggested change
answer := r.read_line('Ask me something: ')!
println('Sorry, I can\'t help you with this. $answer')
answer := r.read_line('Ask me something: ') or {
println('Failed to read input: $err')
return
}
println('Sorry, I can\'t help you with this. $answer')

}