# ScriptGroup.Closure

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Deprecated in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Closure

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/renderscript/ScriptGroup.Closure "View this page in Java")  

```
class Closure : BaseObj
```

|---|---|--------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                          |||
| ↳ | [android.renderscript.BaseObj](https://developer.android.com/reference/kotlin/android/renderscript/BaseObj)                             ||
|   | ↳ | [android.renderscript.ScriptGroup.Closure](https://developer.android.com/reference/kotlin/android/renderscript/ScriptGroup.Closure#) |

*** ** * ** ***

| **This class was deprecated in API level 31.**
|
| Deprecated in Java.

An opaque class for closures

A closure represents a function call to a kernel or invocable function, combined with arguments and values for global variables. A closure is created using the[android.renderscript.ScriptGroup.Builder2#addKernel](https://developer.android.com/reference/kotlin/android/renderscript/ScriptGroup.Builder2#addKernel(android.renderscript.Script.KernelID,%20android.renderscript.Type,%20kotlin.Any))or[android.renderscript.ScriptGroup.Builder2#addInvoke](https://developer.android.com/reference/kotlin/android/renderscript/ScriptGroup.Builder2#addInvoke(android.renderscript.Script.InvokeID,%20kotlin.Any))method.

## Summary

|                                                                                                                                                                                                         Public methods                                                                                                                                                                                                          ||
|---------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                  | [destroy](https://developer.android.com/reference/kotlin/android/renderscript/ScriptGroup.Closure#destroy())`()` Destroys this Closure and the Allocation for its return value                                                                                                                                   |
| [ScriptGroup.Future](https://developer.android.com/reference/kotlin/android/renderscript/ScriptGroup.Future)! | [getGlobal](https://developer.android.com/reference/kotlin/android/renderscript/ScriptGroup.Closure#getGlobal(android.renderscript.Script.FieldID))`(`field:` `[Script.FieldID](https://developer.android.com/reference/kotlin/android/renderscript/Script.FieldID)!`)` Returns the future for a global variable |
| [ScriptGroup.Future](https://developer.android.com/reference/kotlin/android/renderscript/ScriptGroup.Future)! | [getReturn](https://developer.android.com/reference/kotlin/android/renderscript/ScriptGroup.Closure#getReturn())`()` Returns the future for the return value                                                                                                                                                     |

|                                                                                            Protected methods                                                                                            ||
|------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [finalize](https://developer.android.com/reference/kotlin/android/renderscript/ScriptGroup.Closure#finalize())`()` <br /> |

| Inherited functions ||
|---|---|
| From class[BaseObj](https://developer.android.com/reference/kotlin/android/renderscript/BaseObj) |------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [equals](https://developer.android.com/reference/kotlin/android/renderscript/BaseObj#equals(kotlin.Any))`(`other:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?`)` <br /> Compare the current BaseObj with another BaseObj for equality. <br />                                  | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!  | [getName](https://developer.android.com/reference/kotlin/android/renderscript/BaseObj#getName())`()` <br />                                                                                                                                                                                                      | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [hashCode](https://developer.android.com/reference/kotlin/android/renderscript/BaseObj#hashCode())`()` <br /> Calculates the hash code value for a BaseObj. <br />                                                                                                                                               | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [setName](https://developer.android.com/reference/kotlin/android/renderscript/BaseObj#setName(kotlin.String))`(`name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` <br /> setName assigns a name to an object. This object can later be looked up by this name. <br /> | ||

## Public methods

### destroy

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun destroy(): Unit
```

**Deprecated:** *Deprecated in Java.*

Destroys this Closure and the Allocation for its return value  

### getGlobal

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getGlobal(field: Script.FieldID!): ScriptGroup.Future!
```

**Deprecated:** *Deprecated in Java.*

Returns the future for a global variable

|                                                                     Parameters                                                                      ||
|---------|--------------------------------------------------------------------------------------------------------------------------------------------|
| `field` | [Script.FieldID](https://developer.android.com/reference/kotlin/android/renderscript/Script.FieldID)!:the field ID for the global variable |

|                                                         Return                                                          ||
|---------------------------------------------------------------------------------------------------------------|----------|
| [ScriptGroup.Future](https://developer.android.com/reference/kotlin/android/renderscript/ScriptGroup.Future)! | a future |

### getReturn

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getReturn(): ScriptGroup.Future!
```

**Deprecated:** *Deprecated in Java.*

Returns the future for the return value

|                                                         Return                                                          ||
|---------------------------------------------------------------------------------------------------------------|----------|
| [ScriptGroup.Future](https://developer.android.com/reference/kotlin/android/renderscript/ScriptGroup.Future)! | a future |

## Protected methods

### finalize

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
protected fun finalize(): Unit
```

**Deprecated:** *Deprecated in Java.*

|                         Exceptions                         ||
|-----------------------|-------------------------------------|
| `java.lang.Throwable` | the`Exception`raised by this method |