Last active
December 15, 2015 01:59
-
-
Save chris-martin/5184209 to your computer and use it in GitHub Desktop.
"Python’s Pragmatism: This example showcases the ease in which arrays can be created and manipulated. Define a list, print an item in that list, or replace an item with simple methods." - from http://preview.python.org/ 2013-03-17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> l = ['spam', 'ham', 314, 23] | |
>>> l | |
['spam', 'ham', 314, 23] | |
>>> l[0] | |
'spam' | |
>>> l[0] = 'monkey' | |
>>> l | |
['monkey', 'ham', 314, 23] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val l = List("spam", "ham", 314, 23) | |
l: List[Any] = List(spam, ham, 314, 23) | |
scala> l(0) | |
res1: Any = spam | |
scala> l.updated(0, "monkey") | |
res2: List[Any] = List(monkey, ham, 314, 23) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val l = collection.mutable.ArrayBuffer("spam", "ham", 314, 23) | |
l: scala.collection.mutable.ArrayBuffer[Any] = ArrayBuffer(spam, ham, 314, 23) | |
scala> l(0) | |
res1: Any = spam | |
scala> l(0) = "monkey" | |
scala> l | |
res2: scala.collection.mutable.ArrayBuffer[Any] = ArrayBuffer(monkey, ham, 314, 23) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment