how to set boundaries

I’m working on a project and i need to set boundaries on my object, i’ve heard about something called mathf.clamp but i really dont know how to use it

using UnityEngine;
using System.Collections;

public class PaddleControl : MonoBehaviour {
	public float speed = 5f;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	if (Input.GetKey (KeyCode.RightArrow))
			transform.position += new Vector3 (speed * Time.deltaTime, 0.0f, 0.0f);
	if (Input.GetKey (KeyCode.LeftArrow))
			transform.position -= new Vector3 (speed * Time.deltaTime, 0.0f, 0.0f);
				
	}
}

my xmin-xmax are -2.8 and +2.8

i hope someone can help me.
im still a beginner

void Update ()
{

//write this in the last line

vector3 pos=transform.positon;

pos.x=mathf.clamp(pos.x,-2.8f,2.8f);

transform.position=pos;

}

If I understand your goal correctly you’re looking for something like this:

transform.position += new Vector3 (Mathf.Clamp(speed * Time.deltaTime, -2.8f, 2.8f), 0.0f, 0.0f);

You can see more about the Mathf.Clamp class here.