JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

index-of

core-api


    function
    boot.janet on line 1337, column 1

    (index-of val x &opt dflt)

    Find the first key associated with a value `val` in `x`, acting 
    like a reverse lookup. Will not look at dictionary prototypes. If 
    not found, return `dflt` if given, or `nil` otherwise.

    `x` can be a bytes, indexed, dictionary, fiber, or abstract type 
    with suitable `get` and `next` methods.


1 exampleSign in to add an example
Loading...
# in struct 
(index-of 2 {:a 1 :b 2 :c 3 :d 2} )
# => :b

# in table 
(index-of 2 @{:a 1 :b 2 :c 3 :d 2})
# => :b

# in array 
(index-of 6 @[4 5 6 7 8 9] )
# => 2

# in tuple 
(index-of 2 [1 2 3 4])
# => 1
leobmPlayground