Memor.の 2012-11-06 03:45 采纳率: 50%
浏览 244
已采纳

没有开始与,结束与功能在围棋?

Just curious to findout: why aren't there standard functions like startswith, endswith, etc as part of the standard libraries in the Go programming language?

转载于:https://stackoverflow.com/questions/13244048/no-startswith-endswith-functions-in-go

  • 写回答

1条回答 默认 最新

  • 10.24 2012-11-06 03:49
    关注

    The strings package contains HasPrefix and HasSuffix.

    import "strings"
    
    startsWith := strings.HasPrefix("prefix", "pre") // true
    endsWith := strings.HasSuffix("suffix", "fix") // true
    

    play.golang.org

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?