miércoles, 1 de mayo de 2024

Comentarios de documentación




//// A module containing some unusual functions and types.


/// A type where the value can never be constructed.

/// Can you work out why?

pub type Never {

  Never(Never)

}


/// Call a function twice with an initial value.

///

pub fn twice(argument: value, my_function: fn(value) -> value) -> value {

  my_function(my_function(argument))

}


/// Call a function three times with an initial value.

///

pub fn thrice(argument: value, my_function: fn(value) -> value) -> value {

  my_function(my_function(my_function(argument)))

}


La documentación y los comentarios son herramientas importantes para hacer que sea más fácil trabajar y comprender el código.

Además de los // comentarios regulares, Gleam tiene /// y //// comentarios que se utilizan para adjuntar documentación al código.

/// se utiliza para documentar tipos y funciones, y debe colocarse inmediatamente antes del tipo o función que se está documentando.

//// se utiliza para documentar módulos y debe colocarse en la parte superior del módulo.

No hay comentarios.:

Publicar un comentario