Servo motor in a function

I’m building a robot and I want to be able to call movements using functions. Could I have a servo change position in a function?
E.g:

int moveHead(){
servo1.write(95)
return
}

I’m just starting out so would this be possible?

this will not compile
follow syntax rules

Your idea is correct, in that you can have a function that can do something like change the position of a servo to whatever you want.

But your implementation code is not correct.
To just get you started, a function always has to have a return type. Here, you just want to move the servo to a given position, so the functions does not need to return anything. Therefore, the first line might read

void moveHead() {

... and so on.

A good way to go about it would be to write out what you want the function to do in plain language. It will then be much easier to convert that into code.

Yes, you can.

Your function would do it if the syntax were right. You need to terminate the servo write and return lines with semicolon ( ;).

Your function has a return value (int) but the return does not return anything. That will generate a warning. What would that function return?

Have you seen the examples in the Servo libray?

Servo basics.