Post

GoLangGoLang

A
Altaf syed

Posted on 20th February 2024|22 views

0
votes

Golang Slice Contains

Is there any equivalent to slice.contains(object) method in Go?

Answers
P
rushi chowdary

Posted on 20th February 2024

No, such a method does not endure, however, is useless to write:

func contains(r []int, p int) bool {

for _, x := range r {

if x == p {

return true

} } return false }

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos