Scala Get First and Last elements of List using Pattern Matching

I am doing a pattern matching on a list. Is there anyway I can access the first and last element of the list to compare? I want to do something like.. case List(x, _*, y) if(x == y) => true ...