Comprehensive Rust(繁体中文)
let mut strctr = Counter::new(); strctr.count("apple"); strctr.count("orange"); strctr.count("apple"); println!("got {} apples", strctr.times_seen("apple")); } 16.8.1 解決方案 use std::collections::HashMap; let mut strctr = Counter::new(); strctr.count("apple"); strctr.count("orange"); strctr.count("apple"); println!("got {} apples", strctr.times_seen("apple")); } 87 第 17 部分 標準函式庫 This segment should0 码力 | 358 页 | 1.41 MB | 10 月前3julia 1.13.0 DEV
...) Complex blocks: @static if Sys.islinux() linux_specific_thing(a) elseif Sys.isapple() apple_specific_thing(a) else generic_thing(a) end When nesting conditionals, the @static must be repeated expressed using the macro @enum(name, value1, value2, ...) For example: @enum(Fruit, banana=1, apple, pear)CHAPTER 39. NOTEWORTHY DIFFERENCES FROM OTHER LANGUAGES 534 • By convention, functions that Fruit apple=1 orange=2 kiwi=3 julia> f(x::Fruit) = "I'm a Fruit with value: $(Int(x))" f (generic function with 1 method) julia> f(apple) "I'm a Fruit with value: 1" julia> Fruit(1) apple::Fruit0 码力 | 2058 页 | 7.45 MB | 3 月前3julia 1.10.10
...) Complex blocks: @static if Sys.islinux() linux_specific_thing(a) elseif Sys.isapple() apple_specific_thing(a) else generic_thing(a) end When nesting conditionals, the @static must be repeated expressed using the macro @enum(name, value1, value2, ...) For example: @enum(Fruit, banana=1, apple, pear) • By convention, functions that modify their arguments have a ! at the end of the name, for Fruit apple=1 orange=2 kiwi=3 julia> f(x::Fruit) = "I'm a Fruit with value: $(Int(x))" f (generic function with 1 method) julia> f(apple) "I'm a Fruit with value: 1" julia> Fruit(1) apple::Fruit0 码力 | 1692 页 | 6.34 MB | 3 月前3Julia 1.10.9
...) Complex blocks: @static if Sys.islinux() linux_specific_thing(a) elseif Sys.isapple() apple_specific_thing(a) else generic_thing(a) end When nesting conditionals, the @static must be repeated expressed using the macro @enum(name, value1, value2, ...) For example: @enum(Fruit, banana=1, apple, pear) • By convention, functions that modify their arguments have a ! at the end of the name, for Fruit apple=1 orange=2 kiwi=3 julia> f(x::Fruit) = "I'm a Fruit with value: $(Int(x))" f (generic function with 1 method) julia> f(apple) "I'm a Fruit with value: 1" julia> Fruit(1) apple::Fruit0 码力 | 1692 页 | 6.34 MB | 3 月前3Julia 1.12.0 RC1
...) Complex blocks: @static if Sys.islinux() linux_specific_thing(a) elseif Sys.isapple() apple_specific_thing(a) else generic_thing(a) end When nesting conditionals, the @static must be repeated expressed using the macro @enum(name, value1, value2, ...) For example: @enum(Fruit, banana=1, apple, pear)CHAPTER 39. NOTEWORTHY DIFFERENCES FROM OTHER LANGUAGES 535 • By convention, functions that Fruit apple=1 orange=2 kiwi=3 julia> f(x::Fruit) = "I'm a Fruit with value: $(Int(x))" f (generic function with 1 method) julia> f(apple) "I'm a Fruit with value: 1" julia> Fruit(1) apple::Fruit0 码力 | 2057 页 | 7.44 MB | 3 月前3Julia 1.12.0 Beta4
...) Complex blocks: @static if Sys.islinux() linux_specific_thing(a) elseif Sys.isapple() apple_specific_thing(a) else generic_thing(a) end When nesting conditionals, the @static must be repeated expressed using the macro @enum(name, value1, value2, ...) For example: @enum(Fruit, banana=1, apple, pear)CHAPTER 39. NOTEWORTHY DIFFERENCES FROM OTHER LANGUAGES 534 • By convention, functions that Fruit apple=1 orange=2 kiwi=3 julia> f(x::Fruit) = "I'm a Fruit with value: $(Int(x))" f (generic function with 1 method) julia> f(apple) "I'm a Fruit with value: 1" julia> Fruit(1) apple::Fruit0 码力 | 2057 页 | 7.44 MB | 3 月前3Julia 1.12.0 Beta3
...) Complex blocks: @static if Sys.islinux() linux_specific_thing(a) elseif Sys.isapple() apple_specific_thing(a) else generic_thing(a) end When nesting conditionals, the @static must be repeated expressed using the macro @enum(name, value1, value2, ...) For example: @enum(Fruit, banana=1, apple, pear)CHAPTER 39. NOTEWORTHY DIFFERENCES FROM OTHER LANGUAGES 534 • By convention, functions that Fruit apple=1 orange=2 kiwi=3 julia> f(x::Fruit) = "I'm a Fruit with value: $(Int(x))" f (generic function with 1 method) julia> f(apple) "I'm a Fruit with value: 1" julia> Fruit(1) apple::Fruit0 码力 | 2057 页 | 7.44 MB | 3 月前3julia 1.12.0 beta1
...) Complex blocks: @static if Sys.islinux() linux_specific_thing(a) elseif Sys.isapple() apple_specific_thing(a) else generic_thing(a) end When nesting conditionals, the @static must be repeated expressed using the macro @enum(name, value1, value2, ...) For example: @enum(Fruit, banana=1, apple, pear)CHAPTER 39. NOTEWORTHY DIFFERENCES FROM OTHER LANGUAGES 534 • By convention, functions that Fruit apple=1 orange=2 kiwi=3 julia> f(x::Fruit) = "I'm a Fruit with value: $(Int(x))" f (generic function with 1 method) julia> f(apple) "I'm a Fruit with value: 1" julia> Fruit(1) apple::Fruit0 码力 | 2047 页 | 7.41 MB | 3 月前3Julia 1.11.4
...) Complex blocks: @static if Sys.islinux() linux_specific_thing(a) elseif Sys.isapple() apple_specific_thing(a) else generic_thing(a) end When nesting conditionals, the @static must be repeated expressed using the macro @enum(name, value1, value2, ...) For example: @enum(Fruit, banana=1, apple, pear) • By convention, functions that modify their arguments have a ! at the end of the name, for Fruit apple=1 orange=2 kiwi=3 julia> f(x::Fruit) = "I'm a Fruit with value: $(Int(x))" f (generic function with 1 method) julia> f(apple) "I'm a Fruit with value: 1" julia> Fruit(1) apple::Fruit0 码力 | 2007 页 | 6.73 MB | 3 月前3Julia 1.11.5 Documentation
...) Complex blocks: @static if Sys.islinux() linux_specific_thing(a) elseif Sys.isapple() apple_specific_thing(a) else generic_thing(a) end When nesting conditionals, the @static must be repeated expressed using the macro @enum(name, value1, value2, ...) For example: @enum(Fruit, banana=1, apple, pear) • By convention, functions that modify their arguments have a ! at the end of the name, for Fruit apple=1 orange=2 kiwi=3 julia> f(x::Fruit) = "I'm a Fruit with value: $(Int(x))" f (generic function with 1 method) julia> f(apple) "I'm a Fruit with value: 1" julia> Fruit(1) apple::Fruit0 码力 | 2007 页 | 6.73 MB | 3 月前3
共 19 条
- 1
- 2