Skip to content

How can I compare string..? #3463

@ghost

Description

1 import io::;
2 import core::
;
3 fn main(){
4 let price;
5
6 let item = io::stdin().read_line();
7
8 if str::eq(item,"salad"){
9 price = 3.5;
10 }else if str::eq(item,"kiwie"){
11 price = 2.25;
12 }else{
13 price = 5.0;
14 }
15
16 io::println(#fmt("%f",price));
17 }

I used to develope with C but there is a function "strcmp" but here. I don't know which I can use comparing the string..

Let me know them how to use.

Also I'd like to know about how to use API document properly. I can find and see the function and some kind of that. But I don't know how to use exactly

Metadata

Metadata

Assignees

Labels

C-cleanupCategory: PRs that clean code up or issues documenting cleanup.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions